Centos 7 Linux上安装Ansible

从EPEL存储库安装

首先安装启用EPEL存储库:

# yum install epel-release

接下来,安装Ansible:

# yum install ansible

安装后,可以使用“ansible”命令来查询其版本号:

$ansible --version
ansible 2.2.1.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

从源代码安装

安装编译Ansible所需的所有前提条件:

# yum install make git make gcc python-devel libffi-devel openssl-devel epel-release python-sphinx

接下来,安装Python包管理器:

# yum install python-pip

使用git命令下载Ansible源代码:

$git clone git://github.com/ansible/ansible.git
$cd ansible

(可选)使用“Git Checkout”命令选择所需的Ansible版本。
如果未选择Ansible版本,则我们将安装最新的Ansible版本。
在“ANSIBLE”目录中,首先列出所有可用的稳定版本:

$git branch -a | grep stable
  remotes/oroirn/stable-1.9
  remotes/oroirn/stable-2.0
  remotes/oroirn/stable-2.0-network
  remotes/oroirn/stable-2.0.0.1
  remotes/oroirn/stable-2.1
  remotes/oroirn/stable-2.2
  remotes/oroirn/stable-2.3

选择所需版本,例如:

$git checkout stable-2.3

如果一切顺利,我们现在已准备好执行Ansible编译和安装:

$make
# make install

通过查看版本号来检查Ansible安装:

$ansible --version
ansible 2.4.0
  config file = 
  configured module search path = Default w/o overrides
  python version = 2.7.5 (default, Nov  6 2014, 00:28:07) [GCC 4.8.5 20140623 (Red Hat 4.8.5-11)]

常见问题

问题:

error: Installed distribution setuptools 0.9.8 conflicts with requirement setuptools>=11.3

使用以下命令更新Setuptools:

# pip install --upgrade setuptools

问题:

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.

如上所述,请运行以下linux命令以更新Python Package Manager:

# pip install --upgrade pip
日期:2020-07-07 20:57:24 来源:oir作者:oir