1.先安装epel-release源再安装ansible
$ yum -y install epel-release (amazon ec2 使用命令:amazon-linux-extras install epel)
$ yum -y install ansible
$ rpm -qa | grep ansible //查看是否已安装成功
2.安装成功后,接下来配置远程主机清单,写入远程主机ip、端口与相关密钥
$ vim /etc/ansible/hosts
[kafka]
10.32.34.8:22022
10.32.20.102:22022
10.32.21.116:22022
[kafka:vars]
ansible_ssh_user="tier2"
ansible_ssh_private_key_file='/root/logging.pem'
3.使用ping 模块测试能否与远程主机通信
$ ansible kafka -m ping (命令格式: ansible 主机清单中的ip或分组名称 -m 模块)
SUCCESS!