Installation of 1.ansible
Yum-y Install Ansible
2. Then the configuration/etc/ansible/hosts, which mainly records your login IP or alias and login user and password, according to demand I here to all the host divided into 2 categories, [web] and [Orther]
# cp/etc/ansible/hosts/etc/ansible/hosts-#操作前备份
# VI Web #创建web文件, record host IP and password (example below)
1.2.3.4 ASDASD
2.4.5.6 SDSDFG
4.5.7.8 ASDASD
7.5.3.4 ASDAFG
# VI ansible_web.sh #配置把ip和密码按格式批量输
echo "[web]" >>/etc/ansible/hosts into/etc/ansible/hosts script
For i in ' cat Web|awk ' {print $} '
Do
Pass= ' cat web|grep ' $i ' |awk ' {print $} '
echo "$i ansible_ssh_user=root ansible_ssh_pass= $pass >>/etc/ansible/hosts
Done
# bash +x ansible_web.sh
# vi/etc/ansible/hosts #查看脚本是否实现成功
Db-[99:101]-node.example.com
[web]
1.2.3.4 Ansible_ssh_user=root ANSIBLE_SSH_PASS=ASDASD
2.4.5.6 Ansible_ssh_user=root ANSIBLE_SSH_PASS=SDSDFG
4.5.7.8 Ansible_ssh_user=root ANSIBLE_SSH_PASS=ASDASD
7.5.3.4 ansible_ssh_user=root ANSIBLE_SSH_PASS=ASDAFG #成功
# VI Orther #创建orther文件记载web以外的主机
1.1.1.1 ASDASD's IP and root login password
1.1.1.2 ASDASD
1.1.1.3 Asdasa
1.1.1.4 Asdfas
# CP ansible_web.sh ansible_orther.sh
# sed-i ' s/web/orther/g ' ansible_orther.sh #配置orther批量输入ip和密码以及
# bash +x ansible_orther.sh login format to/etc/ansible/hosts
# vi/etc/ansible/hosts #验证是否成功键入
4.5.7.8 Ansible_ssh_user=root ANSIBLE_SSH_PASS=ASDASD
7.5.3.4 Ansible_ssh_user=root ANSIBLE_SSH_PASS=ASDAFG
[Orther]
1.1.1.1 Ansible_ssh_user=root ANSIBLE_SSH_PASS=ASDASD
1.1.1.2 Ansible_ssh_user=root ANSIBLE_SSH_PASS=ASDASD
1.1.1.3 Ansible_ssh_user=root Ansible_ssh_pass=asdasa
1.1.1.4 Ansible_ssh_user=root Ansible_ssh_pass=asdfas
nice! Obviously typing success, so ansible environment has been set up, you can enjoy the bulk processing of these hosts!!
This article is from the "innovation sharing gallop inside and out" blog, please be sure to keep this source http://10554846.blog.51cto.com/10544846/1682750
Quick Layout Ansible Intranet environment