Ansible automated O & M tool learning Manual
1. Introduction to ansible
Common automated O & M tools
Puppet-developed based on Ruby and adopts a C/S architecture. It is highly scalable and SSL-based, and remote command execution is relatively weak.
SaltStack-developed based on Python and adopts the C/S architecture. It is more lightweight than puppet. The configuration syntax uses YMAL to make the configuration script simpler. Ansible-developed based on Pythonparamiko and distributed, with no client required, lightweight, configuration syntax using YMAL and Jinja2 template language, stronger remote command execution operations other DevOps see: https://github.com/geekwolf/sa-scripts/blob/master/devops.md
Ansible is a simple automated O & M management tool that can be used to automatically deploy applications, configure and orchestrate tasks (continuous delivery, no downtime updates, etc ), use the paramiko protocol Library (fabric also uses this), connect to the host through SSH or ZeroMQ, and publish a master version every two months.
Ansible Working Mechanism
Ansible pushes the Ansible module to the managed end through SSH protocol (or Kerberos or LDAP) on the management node. After the execution, the module is automatically deleted. You can use SVN to manage custom modules and orchestrations.
The figure above shows that Ansible consists of five parts:
Ansible: Core Engine
Modules: includes core modules and custom modules of Ansible );
Core Module: The ansible module distributes resources to remote nodes to execute specific tasks or match a specific status.
Custom module: if the core module is insufficient to complete a certain function, you can add a custom module.
Plugins: complements the functions of the module, including connection plug-ins and email plug-ins.
Playbooks: Many translated scripts on the Internet. I personally think it is more reasonable to understand the orchestration. The configuration file defining ansible tasks can define multiple tasks in one script and be automatically executed by ansible, script Execution supports multiple tasks. The control host can run multiple tasks and manage multiple remote hosts at the same time.
Inventory: defines the list of Ansible management hosts
Ansible features
- Automatically deploy application code.
- Automatic System Management configuration.
- Supports continuous delivery automation.
- Supports cloud computing and big data platforms (such as AWS, OpenStack, and VMWare.
- Lightweight. You do not need to install the agent on the client. when updating the agent, you only need to update the agent on the control machine.
- You can write scripts for batch task execution without distributing them to a remote computer.
- It is easier to maintain using Python and the Ruby syntax is too complicated.
- Supports non-root user management and sudo operations.
Use Ansible to efficiently deliver Docker containers
Batch manage remote servers using Ansible
Ansible installation configuration and simple use
Install and use the automation tool Ansible in CentOS 7
Functions and usage of Ansible and Docker
Ansible batch build LAMP Environment
Ansible: a configuration management and IT automation tool
2. Install ansible
Preparations before installation:
1. Because ansible is based on python, check whether python exists first. If you do not need to install ansible (note that the version is too low or may cause installation failure ).
2. Install the dependency package before installing ansible
Yum-y install epel-release
......
Ansible installation:
Yum-y install ansible
.......
After installation, You need to configure the unit:
Vim/etc/ansible/hosts
Here, my unit name is [ccdoop]. below is the configuration of my other two machines (the local machine is test1: 192.168.254.130)
Test2 192.168.254.131
Test3 192.168.254.132
Now ansible is installed.
Test:
Ansible all-m ping
Result: Successful!
Note: because the machine has only one [ccdoop] group, use all. If there are multiple units and you only want to test one group, replace all with the group name, for example:
[Content navigation] |
Page 1st: Installation |
Page 1: Nginx Installation |