pip安装ansible
因为我的Linux的是CentOS Linux release 7.3.1611 (Core),使用的ali仓库源。
我在yum安装的ansible是
[root@node4 ~]# ansible --version
ansible 2.3.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
由于要使用playbook roles模板自动安装nginx,但该版本存在着BUG,所以只能降到ansible 1.9版本(经过亲测,可以使用)。
所以使用python-pip 安装 ansible1.9版本
yum install -y python-pip
pip install ansible==1.9.1
但在pip install ansible==1.9.1,出现pip版本过低的问题。
You are using pip version 8.1.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
[root@node4 src]#
只需将其升级即可
[root@node4 src]# pip install --upgrade pip
如果直接使用pip安装(在此之前为安装过ansible)
pip install ansible==1.9.1
会出现下列问题
compilation terminated.
error: command 'gcc' failed with exit status 1
即使安装成功也找不到配置文件
[root@node4 ansible]# find / -name ansible
/usr/bin/ansible
/usr/lib/python2.7/site-packages/ansible
这是最绝望的!!!!
所以先使用yum 安装一次ansibel再使用pip安装ansible1.9版本
yum install -y ansible
并且查看/etc/ansible是否存在这些配置文件
[root@node4 ansible]# ls /etc/ansible/
ansible.cfg hosts roles
[root@node4 ~]# ansible --version
ansible 2.3.2.0
config file = /etc/ansible/ansible.cfg
configured module search path = Default w/o overrides
python version = 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)]
如果这些文件存在就可以使用
root@node4 ~]# pip install ansible==1.9.1
Collecting ansible==1.9.1
Using cached ansible-1.9.1.tar.gz
Requirement already satisfied: paramiko in /usr/lib/python2.7/site-packages (from ansible==1.9.1)
Requirement already satisfied: jinja2 in /usr/lib64/python2.7/site-packages (from ansible==1.9.1)
Requirement already satisfied: PyYAML in /usr/lib64/python2.7/site-packages (from ansible==1.9.1)
Requirement already satisfied: setuptools in /usr/lib/python2.7/site-packages (from ansible==1.9.1)
Requirement already satisfied: pycrypto>=2.6 in /usr/lib64/python2.7/site-packages (from ansible==1.9.1)
Requirement already satisfied: pyasn1>=0.1.7 in /usr/lib/python2.7/site-packages (from paramiko->ansible==1.9.1)
Requirement already satisfied: bcrypt>=3.1.3 in /usr/lib64/python2.7/site-packages (from paramiko->ansible==1.9.1)
Requirement already satisfied: cryptography>=1.5 in /usr/lib64/python2.7/site-packages (from paramiko->ansible==1.9.1)
Requirement already satisfied: pynacl>=1.0.1 in /usr/lib64/python2.7/site-packages (from paramiko->ansible==1.9.1)
Requirement already satisfied: MarkupSafe>=0.23 in /usr/lib/python2.7/site-packages (from jinja2->ansible==1.9.1)
Requirement already satisfied: six>=1.4.1 in /usr/lib/python2.7/site-packages (from bcrypt>=3.1.3->paramiko->ansible==1.9.1)
Requirement already satisfied: cffi>=1.1 in /usr/lib64/python2.7/site-packages (from bcrypt>=3.1.3->paramiko->ansible==1.9.1)
Requirement already satisfied: idna>=2.1 in /usr/lib/python2.7/site-packages (from cryptography>=1.5->paramiko->ansible==1.9.1)
Requirement already satisfied: enum34; python_version < "3" in /usr/lib/python2.7/site-packages (from cryptography>=1.5->paramiko->ansible==1.9.1)
Requirement already satisfied: ipaddress; python_version < "3" in /usr/lib/python2.7/site-packages (from cryptography>=1.5->paramiko->ansible==1.9.1)
Requirement already satisfied: asn1crypto>=0.21.0 in /usr/lib/python2.7/site-packages (from cryptography>=1.5->paramiko->ansible==1.9.1)
Requirement already satisfied: pycparser in /usr/lib/python2.7/site-packages (from cffi>=1.1->bcrypt>=3.1.3->paramiko->ansible==1.9.1)
Installing collected packages: ansible
Found existing installation: ansible 2.3.2.0
Uninstalling ansible-2.3.2.0:
Successfully uninstalled ansible-2.3.2.0
Running setup.py install for ansible ... done
Successfully installed ansible-1.9.1
大大的Successfully!!!开心
Successfully installed ansible-1.9.1
查看此时的版本
[root@node4 ~]# ansible --version
ansible 1.9.1
configured module search path = None