5, Python automation operations-centralized management platform Ansible

Source: Internet
Author: User

Centralized management platform Ansible

Summary: Ansible is an open source platform for integrated IT system configuration management, application deployment, and specific tasks
Characteristics:
1, deployment is simple, only need to deploy ansible environment in the main control side, the control side does not do any operation
2. The device is managed by default using SSH protocol
3. Centralized management of Master and slave
4, provide a Web management interface and reset API interface--AWX Platform

Ansible Installation and Configuration

1, installation Ansible:yum install–y ansible

2, modify the configuration file:/etc/ansible/hosts, add host IP.

193.192.168.1.1[webservers]192.168.1.1

3, test whether ping Pass: ansible 192.168.118.132–m ping–k

4, set through the key without password login; The host control side generates the private key and the public key, and then copies the public key to the controlled side.

ssh-keygen  -t  rsassh-copy-id -i /root/.ssh/id_rsa.pub [email protected]
Ansible Common module and API1, remote command module

Function: module includes Command,script,shell, can implement shell command remotely.
Example:

ansible 192.168.1.1 -m command -a “free -m”ansible 192.168.1.1 -m script -a “/root/mbb.sh” #被控端执行主动的脚本ansible 192.168.1.1 -m shell -a “/root/mbb.sh” #被控端执行被控端的脚本
2. Copy module (equivalent to SCP)

Function: Host side to the controlled side copy files
Example:

ansible 192.168.1.1 –m copy –a “src=/root/mbb.txt dest=/root/” #把mbb.txt拷贝到被控端的root目录下
3. Stat Module

function: Get status information for remote files
Example:

ansible 192.168.1.1 –m stat –a “path=/root/reboot.bak”
4. Get_url Module

Function: Implement remote download to develop URL to local
Example:

ansible 192.168.1.1 –m get_url –a “path=http://www.baidu.com dest=/tmp/index.html”
5. Yum module (remote Yum installation software)

Features: Linux package management, common with Yum,apt way
Example:

ansible 192.168.1.1 –m yum –a “name=tcping state=latest”ansible 192.168.1.1 -m apt -a “pkg=tcping state=latest”
6. Cron module (make timing plan)

function: Remote host crontab configuration
Example:

ansible 192.168.1.1 -m cron -a "name=‘check dir‘ hour=‘5,2‘ job=‘ls /root > /root/dir.bak‘"
7. Mount module (remote mount)

function: Remote host partition mount
Example:

ansible 192.168.1.1 –m mount –a “name=/mnt/cdrom ”
8. Service Module (Start services)

Function: Management of remote host system services
Example:

ansible 192.168.1.1 -m service -a "name=nginx state=started"
Playbook (to be perfected, need actual)

Playbook is different from the ansible command line execution mode, can be customized configuration, through the YML format to do

Execute Playbook,ansible-playbook nginx.yml

5, Python automation operations-centralized management platform 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.