系統環境:Centos7
這里使用源碼包安裝,因為centos7默認已經安裝了python2.7,所以這里就不用安裝了,否則需要安裝python2.7或者以上版本。當然,最簡單的還是yum安裝:yum install ansible -y
1、下載ansible源碼包
#cd /data
# wget https://releases.ansible.com/ansible/ansible-2.7.5.tar.gz
或者進入到下面這個網頁自行下載需要的軟件包版本
https://releases.ansible.com/ansible/
2、解壓
# tar zxvf ansible-2.7.5.tar.gz
3、安裝
# cd ansible-2.7.5/
# python2.7 setup.py install
安裝過程中報錯如下:
(1)、ext/_yaml.c:4:20: fatal error: Python.h: No such file or directory 提示缺少文件,所以需要安裝python-devel庫
# yum install python-devel -y
(2)、error: Installed distribution cffi 0.8.6 conflicts with requirement cffi>=1.4.1 提示cffi版本太低,下載cffi
# wget https://files.pythonhosted.org/packages/e7/a7/4cd50e57cc6f436f1cc3a7e8fa700ff9b8b4d471620629074913e3735fb2/cffi-1.11.5.tar.gz
或者進入下面的網頁自行下載需要的軟件包版本
https://pypi.python.org/pypi/cffi/
# tar zxvf cffi-1.11.5.tar.gz
# cd cffi-1.11.5/
# python2 setup.py build 執行這一步的時候為了檢查是否報錯,當然,這里報錯了。提示錯誤 fatal error: ffi.h: No such file or directory,所以安裝依賴的庫
# yum install libffi-devel -y
4、繼續安裝
# python2.7 setup.py install
如果安裝過程中缺少什么就安裝什么就行了
5、安裝完檢查版本
[root@runstone ansible-2.7.5]# ansible --version ansible 2.7.5 config file = None 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-2.7.5-py2.7.egg/ansible executable location = /usr/bin/ansible python version = 2.7.5 (default, Oct 30 2018, 23:45:53) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]
ansible配置文件詳解借鑒:https://www.cnblogs.com/LuisYang/p/5960660.html