ansible初始安装配置

1,安装 

yum -y install ansible

2,修改配置文件

vim /etc/ansible/ansible.cfg
host_key_checking = False

3,添加要批量操作的主机,末尾添加

vim /etc/ansible/hosts
[webservers]
10.1.1.35 ansible_ssh_user=root ansible_ssh_pass=root
10.1.1.36 ansible_ssh_user=root ansible_ssh_pass=root
10.1.1.37 ansible_ssh_user=root ansible_ssh_pass=root

4,方法二

生成ssh 秘钥

ssh-keygen -f /root/.ssh/id_rsa -N '' 

 把公钥传给所有主机

 

for i in {35..37}; do ssh-copy-id 10.1.1.$i; done

 

vim /etc/ansible/hosts
[webservers]
10.1.1.35 
10.1.1.36 
10.1.1.37 

 

 

你可能感兴趣的:(ansible)