Several basic statements of ansible

Source: Internet
Author: User

As the signing of the new club, the environment is very good, colleagues are very easy-going, the leadership is also very good to talk, overtime benefits are great, all in all, good work, a lot of money.


Batch processing tool My earliest contact is pssh, because it is very simple and rough, but it is too simple and rough, to cope with 10 sets of 20 machines is OK, to cope with 50 100 servers on the heart of the lack of power, and I do not like puppet, always feel that the thing with my eight, so, In the new boss's recommendation, I put my eyes on the ansible.


Ansible installation is very simple, in the Redhat environment directly #yum install ANSIBLE-Y on the line. Redhat has already acquired the Ansible company, so it offers no small convenience in installation.


Ansible after installation, will be in the/etc/ansible/directory to see a file called hosts, here is all the servers you want to control the IP, you can arrange to write, such as:

192.168.1.122

192.168.1.133

192.168.1.144

You can also write in groups, for example:

[Aliyun]

10.22.33.44

10.22.33.45

[Jinshanyun]

121.23.45.66

121.23.45.67


By default, Ansible will use the command for this hosts file, such as

#ansible all-m Ping 192.168.1.134-u Ashin

This means that the entire hosts in the machine to Ashin account start, and all to ping 192.168.1.134.


How to connect the host with the remote machine to be controlled after that, here are a few command statements:

1) #ansible all-m shell-a "/bin/echo Hello"


2) #ansible all-m copy-a "src=~/projects/tests/t.py dest=~"


3) #ansible all-m file-a "Dest=~/tests state=absent"


4) #ansible webservers-m copy-a ' dest=/root/src=/root/xl2pdf '


5) #ansible v1-m service-a "Name=mysql state=started"--sudo-k


6) #ansible all-m user-a "Name=foo password=foo"--sudo-k


7) #ansible v1-m apt-a "Name=git state=latest"


This article is from "Life is waiting for Gordo" blog, please make sure to keep this source http://chenx1242.blog.51cto.com/10430133/1792509

Several basic statements of ansible

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.