Ansible for simple use

Source: Internet
Author: User
Tags ansible modules

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>

Related Article

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.