zhmg23

我们是如此的不同

在RHEL 7上安装Ansible 2.3

ansible 的用途不解释,之前在CentOS6上安装使用过,因最近大量使用RHEL,所以做个记录,在RHEL7上使用ansible。

第一:安装wget工具

yum install net-tools

yum install wget


第二:安装epel包

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

rpm -ivh epel-release-latest-7.noarch.rpm

yum install epel-release


第三:安装python环境及升级pip

sudo yum install python

sudo yum install python-pip

sudo pip install --upgrade pip


第四:安装ansible

sudo yum install ansible


第五:查看版本

ansible --version

  ansible 2.3.1.0

  config file = /etc/ansible/ansible.cfg

  configured module search path = Default w/o overrides

  python version = 2.7.5 (default, Nov 20 2015, 02:00:19) [GCC 4.8.5 20150623 (Red Hat 4.8.5-4)]


测试

# vi /etc/ansible/hosts 

[mongo]

10.1.73.6 ansible_ssh_user=root  ansible_ssh_pass=123456pass

10.1.73.8 ansible_ssh_user=root  ansible_ssh_pass=123456pass

 

# ansible -m ping mongo

10.1.73.8 | SUCCESS => {

    "changed": false, 

    "ping": "pong"

}

10.1.73.6 | SUCCESS => {

    "changed": false, 

    "ping": "pong"

}                                                                 


如果遇到以下问题:

10.1.73.8 | FAILED! => {

    "failed": true, 

    "msg": "Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this.  Please add this host's fingerprint to your known_hosts file to manage this host."

}

解决:在ansible 服务器上使用ssh 登陆下/etc/ansible/hosts 里面配置的服务器(报错的机器)


评论