Under linux install and use the automated operation and maintenance of tools ansible

ansible python language development is based on modular bulk management tools. ansible endless, based ssh manage; supports master-slave mode, support playbook.
Experiment Environment: 3 sets Centos7, 131 as the master node, node 130, and 132 as controlled.
A, 131 mounted on ansible
(. 1), the install yum ansible -Y
Under linux install and use the automated operation and maintenance of tools ansible
(2), see ansible version
ansible --version
Under linux install and use the automated operation and maintenance of tools ansible
(. 3), the associated file ansible
RPM -qc ansible
/etc/ansible/ansible.cfg arranged #ansible file
/ etc / ansible / hosts #ansible host list
Under linux install and use the automated operation and maintenance of tools ansible
two generated secret key
(. 1), -P RSA SSH-keygen -t ""
Under linux install and use the automated operation and maintenance of tools ansible
(2), the secret key to the hosts
ssh-copy-id -i ~ / . ssh / id_rsa.pub 192.168.70.130
ssh-Copy-ID -i ~ / .ssh / id_rsa.pub 192.168.70.131
ssh-Copy-ID -i ~ / .ssh / id_rsa.pub 192.168.70.132
(. 3), the test
ssh ser132 ip addr
Under linux install and use the automated operation and maintenance of tools ansible
Third, the use ansible manage other nodes
format: ansible <host> [options]
options:
-m: Specifies the name of the module
-a: Specifies the specific parameters of the modules
-s: sudo to run the operation
-i: specify the list of hosts managed nodes
-f: connecting several hosts a number of operations (the default is five host)
View ansible supported module information
ansible-DOC the -l
[default with the command module]
view of a module to help: ansible-doc -s module name
such as command: ansible-doc -s command
ansible is a list of files managed nodes / etc / ansible / hosts
defined when the managed nodes: can be done separately defined based on the host, the host may be defined as a plurality of host group
(1), defined as a host group management node
Vim / etc / ansible / the hosts
[the webserver]
192.168.70.130 info = "the this IS First Server"
192.168.70.132 info = "the this IS SECOND, Server"

Under linux install and use the automated operation and maintenance of tools ansible
Examples: In the management node through the management node being ansible Run
ansible target -m command -a "command"
Description: The target group can be a host, hosts file may be one or more hosts, but also All
-m command: Specifies the command module implements ansible operation is based on
-a "command": that in order to be executed on the management node
(2), executed on all hosts on webserber command to display the host name
ansible webserver -m command -a " hostname "
Under linux install and use the automated operation and maintenance of tools ansible
(. 3), all hosts on the Run display the host name
ansible All command -m -a" hostname "
Under linux install and use the automated operation and maintenance of tools ansible
(. 4), execute the command displayed on the specified host name of the host (132)
ansible 192.168.70.132 -m command -a "hostname"
Under linux install and use the automated operation and maintenance of tools ansible
These are the ansible simple installation and configuration, due to time, ansible module will not describe here. Bloggers white, welcome to point out deficiencies and improvements, thanks for watching.

Really let you run the self-discipline, positive and hard-working!

Guess you like

Origin blog.51cto.com/14015577/2417838