第一节 ansible 软件安装
1.1.1 CentOS7 环境下 yum 安装 ansible
1. 准备一台纯新的 CentOS7.6 服务器,关闭selinux,清空防火墙规则
查看是否关闭selinux,清空防火墙规则。
[root@ansible1 ~]#firewall-cmd --state
not running
[root@ansible1 ~]#getenforce
Disabled
[root@ansible1 ~]#
查看当前系统中的 ansible 版本,默认情况下 yum 的扩展源中包含 ansible 2.9.1-1.el7版本
[root@ansible1 ~]#yum list "*ansible*"
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Installed Packages
ansible.noarch 2.9.1-1.el7 @epel
Available Packages
ansible-doc.noarch 2.9.1-1.el7 epel
ansible-inventory-grapher.noarch 2.4.4-1.el7 epel
ansible-lint.noarch 3.5.1-1.el7 epel
ansible-openstack-modules.noarch 0-20140902git79d751a.el7 epel
ansible-review.noarch 0.13.4-1.el7 epel
kubernetes-ansible.noarch 0.6.0-0.1.gitd65ebd5.el7 epel
python2-ansible-runner.noarch 1.0.1-1.el7 epel
python2-ansible-tower-cli.noarch 3.3.0-2.el7 epel
[root@ansible1 ~]#
[root@ansible1 ~]#yum install ansible -y
安装信息省略......
[root@ansible1 ~]#ansible --version
ansible 2.9.1
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
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Aug 7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
1.1.2 CentOS7环境下 python pip 安装 ansible 2.9.1,这里选择ansible2主机纯净系统进行安装
#查看是否关闭selinux,清空防火墙规则
[root@ansible2 ~]#
[root@ansible2 ~]#firewall-cmd --state
not running
[root@ansible2 ~]#getenforce
Disabled
[root@ansible2 ~]#
#安装 epel 源:
[root@ansible2 ~]#yum install epel-release -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
centos7 | 3.6 kB 00:00:00
epel | 5.3 kB 00:00:00
https://mirrors.tuna.tsinghua.edu.cn/percona/release/7/RPMS/x86_64/repodata/repomd.xml: [Errno 12]
Timeout on https://mirrors.tuna.tsinghua.edu.cn/percona/release/7/RPMS/x86_64/repodata/repomd.xml: (28,
'Operation timed out after 30001 milliseconds with 0 out of 0 bytes received')
Trying other mirror.
percona | 2.9 kB 00:00:00
(1/2): epel/updateinfo | 1.0 MB 00:00:00
(2/2): epel/primary_db | 6.9 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package epel-release.noarch 0:7-12 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================
Package Arch Version Repository Size
===================================================================================================================
Installing:
epel-release noarch 7-12 epel 15 k
Transaction Summary
===================================================================================================================
Install 1 Package
Total download size: 15 k
Installed size: 24 k
Downloading packages:
epel-release-7-12.noarch.rpm | 15 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : epel-release-7-12.noarch 1/1
Verifying : epel-release-7-12.noarch 1/1
Installed:
epel-release.noarch 0:7-12
Complete!
[root@ansible2 ~]#
#安装 python36 并更新 pip 版本:
[root@ansible2 ~]#yum list python36
Loaded plugins: fastestmirror
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Error: No matching Packages to list
[root@ansible2 ~]#yum install python36 python36-pip -y
Loaded plugins: fastestmirror
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package python3.x86_64 0:3.6.8-10.el7 will be installed
--> Processing Dependency: python3-libs(x86-64) = 3.6.8-10.el7 for package: python3-3.6.8-10.el7.x86_64
--> Processing Dependency: python3-setuptools for package: python3-3.6.8-10.el7.x86_64
--> Processing Dependency: libpython3.6m.so.1.0()(64bit) for package: python3-3.6.8-10.el7.x86_64
---> Package python3-pip.noarch 0:9.0.3-5.el7 will be installed
--> Running transaction check
---> Package python3-libs.x86_64 0:3.6.8-10.el7 will be installed
---> Package python3-setuptools.noarch 0:39.2.0-10.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================
Package Arch Version Repository Size
===================================================================================================================
Installing:
python3 x86_64 3.6.8-10.el7 centos7 69 k
python3-pip noarch 9.0.3-5.el7 centos7 1.8 M
Installing for dependencies:
python3-libs x86_64 3.6.8-10.el7 centos7 7.0 M
python3-setuptools noarch 39.2.0-10.el7 centos7 629 k
Transaction Summary
===================================================================================================================
Install 2 Packages (+2 Dependent packages)
Total download size: 9.4 M
Installed size: 48 M
Downloading packages:
(1/4): python3-3.6.8-10.el7.x86_64.rpm | 69 kB 00:00:00
(2/4): python3-pip-9.0.3-5.el7.noarch.rpm | 1.8 MB 00:00:00
(3/4): python3-setuptools-39.2.0-10.el7.noarch.rpm | 629 kB 00:00:00
(4/4): python3-libs-3.6.8-10.el7.x86_64.rpm | 7.0 MB 00:00:01
-------------------------------------------------------------------------------------------------------------------
Total 9.1 MB/s | 9.4 MB 00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python3-setuptools-39.2.0-10.el7.noarch 1/4
Installing : python3-pip-9.0.3-5.el7.noarch 2/4
Installing : python3-3.6.8-10.el7.x86_64 3/4
Installing : python3-libs-3.6.8-10.el7.x86_64 4/4
Verifying : python3-libs-3.6.8-10.el7.x86_64 1/4
Verifying : python3-setuptools-39.2.0-10.el7.noarch 2/4
Verifying : python3-pip-9.0.3-5.el7.noarch 3/4
Verifying : python3-3.6.8-10.el7.x86_64 4/4
Installed:
python3.x86_64 0:3.6.8-10.el7 python3-pip.noarch 0:9.0.3-5.el7
Dependency Installed:
python3-libs.x86_64 0:3.6.8-10.el7 python3-setuptools.noarch 0:39.2.0-10.el7
Complete!
[root@ansible2 ~]#
[root@ansible2 ~]#pip3 install --upgrade pip
WARNING: Running pip install with root privileges is generally not a good idea. Try `pip3 install --user` instead.
Collecting pip
Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-
19.3.1-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 1.6MB/s
Installing collected packages: pip
Successfully installed pip-19.3.1
[root@ansible2 ~]#
[root@ansible2 ~]#
[root@ansible2 ~]#bash -r
[root@ansible2 ~]# pip3 -V
pip 19.3.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)
[root@ansible2 ~]#
[root@ansible2 ~]# pip3 install ansible
Collecting ansible
Downloading https://files.pythonhosted.org/packages/4b/c5/fb70a2d9817eb48c358a67952ed3a1869e5cda8a5e4f1911cffc75f42375/ansible
-2.9.1.tar.gz (14.1MB)
|████████████████████████████████| 14.2MB 630kB/s
Collecting jinja2
Downloading https://files.pythonhosted.org/packages/65/e0/eb35e762802015cab1ccee04e8a277b03f1d8e53da3ec3106882ec42558b/Jinja2
-2.10.3-py2.py3-none-any.whl (125kB)
|████████████████████████████████| 133kB 82.9MB/s
Collecting PyYAML
Downloading https://files.pythonhosted.org/packages/8d/c9/e5be955a117a1ac548cdd31e37e8fd7b02ce987f9655f5c7563c656d5dcb/PyYAML
-5.2.tar.gz (265kB)
|████████████████████████████████| 266kB 57.5MB/s
Collecting cryptography
Downloading https://files.pythonhosted.org/packages/ca/9a/7cece52c46546e214e10811b36b2da52ce1ea7fa203203a629b8dfadad53/
cryptography-2.8-cp34-abi3-manylinux2010_x86_64.whl (2.3MB)
|████████████████████████████████| 2.3MB 49.8MB/s
Collecting MarkupSafe>=0.23
Downloading https://files.pythonhosted.org/packages/b2/5f/23e0023be6bb885d00ffbefad2942bc51a620328ee910f64abe5a8d18dd1/
MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl
Collecting cffi!=1.11.3,>=1.8
Downloading https://files.pythonhosted.org/packages/49/72/0d42f94fe94afa8030350c26e9d787219f3f008ec9bf6b86c66532b29236/
cffi-1.13.2-cp36-cp36m-manylinux1_x86_64.whl (397kB)
|████████████████████████████████| 399kB 57.5MB/s
Collecting six>=1.4.1
Downloading https://files.pythonhosted.org/packages/65/26/32b8464df2a97e6dd1b656ed26b2c194606c16fe163c695a992b36c11cdf/six-1.13.0-
py2.py3-none-any.whl
Collecting pycparser
Downloading https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-
2.19.tar.gz (158kB)
|████████████████████████████████| 163kB 74.6MB/s
Installing collected packages: MarkupSafe, jinja2, PyYAML, pycparser, cffi, six, cryptography, ansible
Running setup.py install for PyYAML ... done
Running setup.py install for pycparser ... done
Running setup.py install for ansible ... done
Successfully installed MarkupSafe-1.1.1 PyYAML-5.2 ansible-2.9.1 cffi-1.13.2 cryptography-2.8 jinja2-2.10.3 pycparser-
2.19 six-1.13.0
[root@ansible2 ~]# ansible --version
ansible 2.9.1
config file = None
configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
ansible python module location = /usr/local/lib/python3.6/site-packages/ansible
executable location = /usr/local/bin/ansible
python version = 3.6.8 (default, Aug 7 2019, 17:28:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
[root@ansible2 ~]#
[root@ansible2 ~]#
1.1.3 CentOS7环境下源码编译安装 ansible2.8.2 版本 (***)
[root@ansible3 ~]#
[root@ansible3 ~]#firewall-cmd --state
not running
[root@ansible3 ~]#getenforce
Disabled
[root@ansible3 ~]#yum install wget -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
centos7 | 3.6 kB 00:00:00
epel | 5.3 kB 00:00:00
(1/2): epel/updateinfo | 1.0 MB 00:00:00
(2/2): epel/primary_db | 6.9 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.14-18.el7_6.1 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================
Package Arch Version Repository Size
===================================================================================================================
Installing:
wget x86_64 1.14-18.el7_6.1 centos7 547 k
Transaction Summary
===================================================================================================================
Install 1 Package
Total download size: 547 k
Installed size: 2.0 M
Downloading packages:
wget-1.14-18.el7_6.1.x86_64.rpm | 547 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : wget-1.14-18.el7_6.1.x86_64 1/1
Verifying : wget-1.14-18.el7_6.1.x86_64 1/1
Installed:
wget.x86_64 0:1.14-18.el7_6.1
Complete!
[root@ansible3 ~]#yum install python2-pip -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package python2-pip.noarch 0:8.1.2-10.el7 will be installed
--> Processing Dependency: python-setuptools for package: python2-pip-8.1.2-10.el7.noarch
--> Running transaction check
---> Package python-setuptools.noarch 0:0.9.8-7.el7 will be installed
--> Processing Dependency: python-backports-ssl_match_hostname for package: python-setuptools-0.9.8-7.el7.noarch
--> Running transaction check
---> Package python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7 will be installed
--> Processing Dependency: python-ipaddress for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Processing Dependency: python-backports for package: python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch
--> Running transaction check
---> Package python-backports.x86_64 0:1.0-8.el7 will be installed
---> Package python-ipaddress.noarch 0:1.0.16-2.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
===================================================================================================================
Package Arch Version Repository Size
===================================================================================================================
Installing:
python2-pip noarch 8.1.2-10.el7 epel 1.7 M
Installing for dependencies:
python-backports x86_64 1.0-8.el7 centos7 5.8 k
python-backports-ssl_match_hostname noarch 3.5.0.1-1.el7 centos7 13 k
python-ipaddress noarch 1.0.16-2.el7 centos7 34 k
python-setuptools noarch 0.9.8-7.el7 centos7 397 k
Transaction Summary
===================================================================================================================
Install 1 Package (+4 Dependent packages)
Total download size: 2.1 M
Installed size: 9.4 M
Downloading packages:
(1/5): python-backports-1.0-8.el7.x86_64.rpm | 5.8 kB 00:00:00
(2/5): python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch.rpm | 13 kB 00:00:00
(3/5): python-ipaddress-1.0.16-2.el7.noarch.rpm | 34 kB 00:00:00
(4/5): python-setuptools-0.9.8-7.el7.noarch.rpm | 397 kB 00:00:00
(5/5): python2-pip-8.1.2-10.el7.noarch.rpm | 1.7 MB 00:00:00
-------------------------------------------------------------------------------------------------------------------
Total 3.8 MB/s | 2.1 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : python-backports-1.0-8.el7.x86_64 1/5
Installing : python-ipaddress-1.0.16-2.el7.noarch 2/5
Installing : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 3/5
Installing : python-setuptools-0.9.8-7.el7.noarch 4/5
Installing : python2-pip-8.1.2-10.el7.noarch 5/5
Verifying : python-ipaddress-1.0.16-2.el7.noarch 1/5
Verifying : python-setuptools-0.9.8-7.el7.noarch 2/5
Verifying : python-backports-ssl_match_hostname-3.5.0.1-1.el7.noarch 3/5
Verifying : python-backports-1.0-8.el7.x86_64 4/5
Verifying : python2-pip-8.1.2-10.el7.noarch 5/5
Installed:
python2-pip.noarch 0:8.1.2-10.el7
Dependency Installed:
python-backports.x86_64 0:1.0-8.el7 python-backports-ssl_match_hostname.noarch 0:3.5.0.1-1.el7
python-ipaddress.noarch 0:1.0.16-2.el7 python-setuptools.noarch 0:0.9.8-7.el7
Complete!
[root@ansible3 ~]#pip install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/00/b6/9cfa56b4081ad13874b0c6f96af8ce16cfbc1cb06bedf8e9164ce5551ec1/pip-19.3.1-
py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 1.3MB/s
Installing collected packages: pip
Found existing installation: pip 8.1.2
Uninstalling pip-8.1.2:
Successfully uninstalled pip-8.1.2
Successfully installed pip-19.3.1
[root@ansible3 ~]#pip install --upgrade setuptools
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7
wont be maintained after that date. A future version of pip will drop support for Python 2.7. More details about Python
2 support in pip, can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting setuptools
Downloading https://files.pythonhosted.org/packages/54/28/c45d8b54c1339f9644b87663945e54a8503cfef59cf0f65b3ff5dd17cf64/setuptools-
42.0.2-py2.py3-none-any.whl (583kB)
|████████████████████████████████| 583kB 488kB/s
Installing collected packages: setuptools
Found existing installation: setuptools 0.9.8
Uninstalling setuptools-0.9.8:
Successfully uninstalled setuptools-0.9.8
Successfully installed setuptools-42.0.2
[root@ansible3 ~]#wget https://github.com/ansible/ansible/archive/v2.8.2.tar.gz
--2019-12-04 20:20:34-- https://github.com/ansible/ansible/archive/v2.8.2.tar.gz
Resolving github.com (github.com)... 13.250.177.223
Connecting to github.com (github.com)|13.250.177.223|:443... connected.
HTTP request sent, awaiting response... 302 Found
Location: https://codeload.github.com/ansible/ansible/tar.gz/v2.8.2 [following]
--2019-12-04 20:20:35-- https://codeload.github.com/ansible/ansible/tar.gz/v2.8.2
Resolving codeload.github.com (codeload.github.com)... 13.229.189.0
Connecting to codeload.github.com (codeload.github.com)|13.229.189.0|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘v2.8.2.tar.gz’
[ <=> ] 14,623,914 729KB/s in 22s
2019-12-04 20:20:58 (658 KB/s) - ‘v2.8.2.tar.gz’ saved [14623914]
[root@ansible3 ~]#ll
total 14288
-rw-------. 1 root root 1572 Dec 3 13:25 anaconda-ks.cfg
-rw-r--r-- 1 root root 14623914 Dec 4 20:20 v2.8.2.tar.gz
[root@ansible3 ~]#tar xf v2.8.2.tar.gz
[root@ansible3 ~]#ll
total 14292
-rw-------. 1 root root 1572 Dec 3 13:25 anaconda-ks.cfg
drwxrwxr-x 11 root root 4096 Jul 4 01:36 ansible-2.8.2
-rw-r--r-- 1 root root 14623914 Dec 4 20:20 v2.8.2.tar.gz
[root@ansible3 ~]#cd ansible-2.8.2/
[root@ansible3 ansible-2.8.2]#
[root@ansible3 ansible-2.8.2]#
[root@ansible3 ~]#python setup.py build
编译内容省略......
[root@ansible3 ~]#python setup.py install
编译内容部分省略......
pycparser.ply.yacc: module references __file__
pycparser.ply.yacc: module MAY be using inspect.getsourcefile
pycparser.ply.yacc: module MAY be using inspect.stack
pycparser.ply.ygen: module references __file__
creating /usr/lib/python2.7/site-packages/pycparser-2.19-py2.7.egg
Extracting pycparser-2.19-py2.7.egg to /usr/lib/python2.7/site-packages
Adding pycparser 2.19 to easy-install.pth file
Installed /usr/lib/python2.7/site-packages/pycparser-2.19-py2.7.egg
Searching for ipaddress==1.0.16
Best match: ipaddress 1.0.16
Adding ipaddress 1.0.16 to easy-install.pth file
Using /usr/lib/python2.7/site-packages
Finished processing dependencies for ansible==2.8.2
[root@ansible3 ansible-2.8.2]#cd
[root@ansible3 ~]#ll
total 14292
-rw-------. 1 root root 1572 Dec 3 13:25 anaconda-ks.cfg
drwxrwxr-x 13 root root 4096 Dec 4 20:23 ansible-2.8.2
-rw-r--r-- 1 root root 14623914 Dec 4 20:20 v2.8.2.tar.gz
[root@ansible3 ~]#
[root@ansible3 ~]#ll /usr/lib/python2.7/site-packages/
total 808
drwxr-xr-x 4 root root 37 Dec 4 20:24 ansible-2.8.2-py2.7.egg
drwxr-xr-x 3 root root 91 Dec 4 20:20 backports
-rw-r--r-- 1 root root 4051 Apr 11 2018 backports.ssl_match_hostname-3.5.0.1-py2.7.egg-info
drwxr-xr-x 5 root root 84 Dec 4 20:25 cffi-1.13.2-py2.7-linux-x86_64.egg
-rw-r--r--. 1 root root 2135 Jun 10 2014 configobj-4.7.2-py2.7.egg-info
-rw-r--r--. 1 root root 88163 Feb 28 2010 configobj.py
-rw-r--r--. 2 root root 66278 Jun 10 2014 configobj.pyc
-rw-r--r--. 2 root root 66278 Jun 10 2014 configobj.pyo
drwxr-xr-x 4 root root 42 Dec 4 20:25 cryptography-2.8-py2.7-linux-x86_64.egg
drwxr-xr-x. 2 root root 110 Dec 3 13:23 decorator-3.4.0-py2.7.egg-info
-rw-r--r--. 1 root root 10639 Oct 18 2012 decorator.py
-rw-r--r--. 1 root root 8563 Jun 10 2014 decorator.pyc
-rw-r--r--. 1 root root 8516 Jun 10 2014 decorator.pyo
-rw-r--r-- 1 root root 284 Dec 4 20:25 easy-install.pth
-rw-r--r-- 1 root root 126 Dec 4 20:23 easy_install.py
-rw-r--r-- 1 root root 317 Dec 4 20:23 easy_install.pyc
drwxr-xr-x 4 root root 34 Dec 4 20:25 enum34-1.1.6-py2.7.egg
drwxr-xr-x. 5 root root 4096 Dec 3 13:23 firewall
drwxr-xr-x. 2 root root 265 Dec 3 13:23 iniparse
-rw-r--r--. 1 root root 1083 Jun 10 2014 iniparse-0.4-py2.7.egg-info
-rw-r--r-- 1 root root 783 Nov 6 2016 ipaddress-1.0.16-py2.7.egg-info
-rw-r--r-- 1 root root 79904 Dec 29 2015 ipaddress.py
-rw-r--r-- 1 root root 75525 Nov 6 2016 ipaddress.pyc
-rw-r--r-- 1 root root 75335 Nov 6 2016 ipaddress.pyo
drwxr-xr-x 4 root root 36 Dec 4 20:25 Jinja2-2.10.3-py2.7.egg
drwxr-xr-x 4 root root 40 Dec 4 20:25 MarkupSafe-1.1.1-py2.7-linux-x86_64.egg
drwxr-xr-x 4 root root 116 Dec 4 20:20 pip
drwxr-xr-x 2 root root 130 Dec 4 20:20 pip-19.3.1.dist-info
drwxr-xr-x 4 root root 117 Dec 4 20:23 pkg_resources
drwxr-xr-x. 2 root root 227 Dec 3 13:23 procfs
drwxr-xr-x 4 root root 39 Dec 4 20:25 pycparser-2.19-py2.7.egg
-rw-r--r--. 1 root root 350 Aug 9 10:08 python_linux_procfs-0.4.9-py2.7.egg-info
drwxr-xr-x. 2 root root 4096 Dec 3 13:23 pyudev
drwxr-xr-x. 2 root root 90 Dec 3 13:23 pyudev-0.15-py2.7.egg-info
-rw-r--r-- 1 root root 101762 Dec 4 20:25 PyYAML-5.2-py2.7-linux-x86_64.egg
drwxr-xr-x. 2 root root 238 Dec 3 13:23 rpmUtils
drwxr-xr-x 5 root root 4096 Dec 4 20:23 setuptools
drwxr-xr-x 2 root root 170 Dec 4 20:23 setuptools-42.0.2.dist-info
drwxr-xr-x 3 root root 36 Dec 4 20:25 six-1.13.0-py2.7.egg
drwxr-xr-x. 5 root root 106 Dec 3 13:23 slip
-rw-r--r--. 1 root root 196 Apr 11 2018 slip-0.4.0-py2.7.egg-info
-rw-r--r--. 1 root root 269 Apr 11 2018 slip.dbus-0.4.0-py2.7.egg-info
drwxr-xr-x. 12 root root 4096 Dec 3 13:23 tuned
drwxr-xr-x. 2 root root 4096 Dec 3 13:23 urlgrabber
-rw-r--r--. 1 root root 2265 Oct 31 2018 urlgrabber-3.10-py2.7.egg-info
-rw-r--r--. 1 root root 46303 Jun 10 2014 validate.py
-rw-r--r--. 2 root root 46711 Jun 10 2014 validate.pyc
-rw-r--r--. 2 root root 46711 Jun 10 2014 validate.pyo
drwxr-xr-x. 2 root root 4096 Dec 3 13:23 yum
[root@ansible3 ~]#
[root@ansible3 ~]#ansible --version
ansible 2.8.2
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.8.2-py2.7.egg/ansible
executable location = /usr/bin/ansible
python version = 2.7.5 (default, Aug 7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
命令小结
1.PEL源的rpm包安装,直接安装即可
yum install ansible
2.python pip 安装
pip是安装Python包的管理器,类似yum
yum install epel-release -y
yum list python36
yum install python36 python36-pip -y
pip3 install --upgrade pip
bash -r
pip3 -V
pip3 install ansible
3.源码编译安装
yum install wget -y
yum install python2-pip -y
pip install --upgrade pip
pip install --upgrade setuptools
wget https://github.com/ansible/ansible/archive/v2.8.2.tar.gz
tar xf v2.8.2.tar.gz
cd ansible-2.8.2/
python setup.py build
python setup.py install
mkdir /etc/ansible
cp -r examples/* /etc/ansible