Quick Layout Ansible Intranet environment

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.