安装
有如下安装方式
# rpm包方式安装
EPEL源
- 当在Linux系统中使用yum安装软件时提示 “没有可用软件包”时,代表在linux系统yum源中已经没有对应的安装包,需要安装EPEL
- EPEL(Extra Packages for Enterprise Linux),企业版Linux额外包,RHEL分布非标准包的社区类库
- 安装如下:
yum install -y epel-release
1
检查版本
[root@linux101 ~]# yum info ansible
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
epel/x86_64/metalink | 17 kB 00:00:00 ...
可安装的软件包
名称 :ansible
架构 :noarch
版本 :2.9.27
发布 :1.el7
大小 :17 M
源 :epel/x86_64
简介 : SSH-based configuration management, deployment, and task execution system
网址 :http://ansible.com
协议 : GPLv3+
描述 : Ansible is a radically simple model-driven configuration management,
: multi-node deployment, and remote task execution system. Ansible works
: over SSH and does not require any software or daemons to be installed
: on remote nodes. Extension modules can be written in any language and
: are transferred to managed machines automatically.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
安装
yum install ansible -y
1
验证版本
- 返回值包含ansible版本,配置文件的路径,模块的路径,python版本,
[root@linux101 ~]# ansible --version
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/site-packages/ansible #ansible对应的模块地址
executable location = /usr/bin/ansible # 二进制ansible程序所在的位置
python version = 2.7.5 (default, Nov 16 2020, 22:23:17) [GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]
[root@linux101 ~]# file /usr/bin/ansible
/usr/bin/ansible: symbolic link to `/usr/bin/ansible-2.7'
[root@linux101 ~]# ll /usr/bin/ansible
lrwxrwxrwx. 1 root root 20 5月 14 20:43 /usr/bin/ansible -> /usr/bin/ansible-2.7 # 使用软链接指向(灰度发布也是使用软连接进行实现的)
1
2
3
4
5
6
7
8
9
10
11
12
13
2
3
4
5
6
7
8
9
10
11
12
13
查看ansible中包含的文件列表
rpm -ql ansible | less
1
查看模块的file文件
rpm -ql ansible | grep file.py
1
# 编译方式安装
yum -y install python-jinja2 PyYAML python-paramiko python-babel
python-crypto
tar xf ansible-1.5.4.tar.gz
cd ansible-1.5.4
python setup.py build
python setup.py install
mkdir /etc/ansible
cp -r examples/* /etc/ansible
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
# Git方式安装
git clone git://github.com/ansible/ansible.git --recursive
cd ./ansible
source ./hacking/env-setup
1
2
3
2
3
# pip方式安装
pip是安装Python包的管理器,类似yum
yum install python-pip python-devel
yum install gcc glibc-devel zibl-devel rpm-bulid openssl-devel
pip install --upgrade pip
pip install ansible --upgrade
1
2
3
4
2
3
4
# 确认安装是否成功
ansible --version
1
Last Updated: 2022/05/22, 13:02:53