I. Ansible Introduction
Ansbile is a powerful python-based batchcompute Command Execution tool. It has powerful functions in managing a large number of clusters. It is small in size and has little dependencies, and has a general trend.
II. Install
The ansible Binary Package is provided in RHEL6. When using CentOS6, you may need to add an epel source.
# yum install ansible
After installation, two ansible. cfg hosts files are generated in the/etc/ansible/directory.
3. Use
Demo Environment Introduction: three nodes, node1, node2, and node3, add the following information in/etc/hosts
172.16.0.1 node1172.16.0.2 node2172.16.0.3 node3
You only need to install ansible on one server. node1 is used as the "host"
1. node1 generates a key and pushes it to node2 and node3.
# Ssh-copy-id node {1, 2, 3)
2. edit/etc/ansible/hosts, comment all content, and add the following information:
[test]node1node2node3
The IP address corresponding to the host name must be included in/etc/hosts.
3. view the ansible help document
# Man ansible
Usage: ansible
4. Test
#ansible test -a "date"
5. Common ansible modules and functions
Yum, user, common
# Yum all-a "ntpdate 172.16.0.100" (synchronize all nodes with the time server. The common module is used by default and can be omitted) # yum all-m yum-a "name = htop state = present" (use the yum module to install htop on all nodes. For the yum module, Run man ansible. yum) # yum all-m cron-a 'name = time minute = "*/3" job = "ntpdate 172.16.0.100 &>/dev/null" '(create a cron task for all nodes, update every 3 minutes)
For more information, see man ansible. <module>