ansible 安装及基本使用

☆樱花仙子☆ 提交于 2020-01-16 05:30:21

1、yum 安装

yum -y install epel-releaseyum -y install ansible 

ansible 配置秘钥

ssh-keygen -t rsa   #直接回车不用设置密码

 公钥copy 到需要批量的主机上

[root@vick ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.99.130
[root@vick ~]# ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.99.180

2、ansible 基本使用

(1)ansible 执行远程命令

 

[root@vick ansible]# ansible -i /etc/ansible/hostname all -m command -a 'hostname'
192.168.99.180 | SUCCESS | rc=0 >>
ansible.vick02.com

192.168.99.130 | SUCCESS | rc=0 >>
ansible.vick01.com

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!