Chapter 10: layman Ansible

1.Ansible Introduction

1) .Ansible advantages

    Ansible is a simple automation engine, complete configuration management, citing the deployment, service orchestration, and other IT requirements

    Ansible is to develop and implement Python open-source software that relies Jinja2, paramiko and PyYAML these Python library

    Simple installation and deployment

    SSH-based configuration management

    Ansible not require daemon

    Log centralized storage

    Ansible easy to use

    Ansible powerful

    Ansible Design Excellence

    Ansible have very good support for cloud computing and big data platform

2) a comparison between .Ansible and Fabric

    Fabric is like a toolbox provides an execution command many useful tools for remote server

    Ansible provides a simple process, just do it in accordance with the process can easily complete the task

    Fabric is a library, Ansible framework

    Fabric simple, Ansible complex

    Fabric via SSH to perform simple commands, Ansible module will be copied to a remote server to perform later, after executing the delete module

    Fabric requires Python programming background, Ansible do not need

    Fabric need to write code, Ansible only need to write YAML configuration file format to describe things to do

    Fabric provides the basic interface, business logic, require the user to achieve, Ansible provides a number of modules, users only need to use the learning module

3) Comparison between .Ansible and SaltStack

    Ansible installation is simple to deploy, SaltStack need to install the client receives the server commands delivered

    SaltStack corresponding faster, Ansible using standard SSH connection, and communicate with SaltStack transmission using ZeroMQ

    Ansible safer, Ansible using standard SSH connection to transfer data, do not start the daemon on the remote host

    SaltStack more friendly to Windows Support

    Ansible their operation and maintenance is relatively simple, SaltStack need to start a daemon and Minion Master Host

 

2.Ansible Getting Started

1). Installation Ansible

    pip install ansible

2) .Ansible architecture

    Ansible orchestration engine by the Inventory, API, Modules (modules) and a composition Plugins

    Engineers will need to perform the operation of the remote server written in Ansible Playbook, and then use the operating Ansible execution of Playbook

3) .Ansible operating environment

Ansible will default read / etc / ansible / remote server list hosts file configuration
 # mkdir / etc / ansible 
# CAT / etc / ansible / hosts 
[the Test]
 192.168.1.101 
192.168.1.102 
192.168.1.103 # ansible the Test -m the ping 
192.168.1.101 | SUCCESS => {
     " changed " : to false, 
     " of ping " : " Pong " 
} 192.168.1.102 | SUCCESS => {
     " changed " : to false, 
     " of ping " : " Pong " 
}



192.168.1.103 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}

4) .Ansible the ad-hoc mode

Ansible the ad-hoc mode, the operation mode performed by ansible orders called ad- hoc
 # ansible Test Command -m -a "hostname" 

# ansible Test Command -m -a "the whoami" 

to copy a local file to the server: 
# ansible the Test Copy -a -m "src = / etc / ansible / hosts dest = / tmp / hosts" 

owner and permission to modify the file: 
# ansible All file -a -m "dest = / tmp / hosts the MODE = 500 = = MySQL MySQL Group owner "-become 
- Become parameters are similar to sudo under Linux commands 

to install the software on a remote server: 
# ansible the Test yum -a -m" name = = Present State git "-become

5) using the control server playbook

 

In the actual production environment, we generally remote server needs to be done in a YAML configuration file written in 
YAML file called Playbook Ansible 

# CAT test_playbook.yaml 
--- 
- hosts: the Test 
  Become: yes 
  become_method: sudo 
  Tasks:
   - name: Copy File 
    Copy: the src = / etc / ansible / dest = the hosts / tmp / data.txt

   - name: Change MODE 
    File: dest = / tmp / owner data.txt MODE = 500 = = Group MySQL MySQL

   - name: Ensure® Installed Packages 
    yum: PKG = " {{}} Item " State = Present 
    with_items:
     - Git 

# ansible-playbook test_playbook.yaml

 

3.Inventory management

 

4.YAML grammar

 

5.Ansible module

 

6.Playbook

 

Definition and use of 7.role

 

8.Ansible profile

 

Guess you like

Origin www.cnblogs.com/allenhu320/p/11354121.html