Introduction: Ansible is a new automated operations tools, based on Python development, the collection of many operations tools (puppet, Cfengine, Chef, func, fabric) The advantages of the implementation of batch system configuration, batch program deployment, batch Run command and other functions. Ansible is a module-based operation and does not have the capacity to deploy in bulk. The real batch deployment is the module that Ansible runs, and Ansible just provides a framework. Mainly includes: 1. Connection plug-in connection plugins: responsible and monitored to achieve communication; 2. Host Inventory: Specifies the operation of the hosts, is a configuration file inside the definition of monitoring host; 3. Various modules core module, command module, custom module, 4. With the help of the plug-in to complete logging mail and other functions; 5. Playbook: When a script performs multiple tasks, it is not necessary to have the node run multiple tasks at once. Ansible Automation Operation Environment has control host and management host, because Ansible is based on SSH protocol communication, so the control host installation Ansible software does not need to restart or run any program, managed host also does not need to install and run any agent. Environment deployment:
role |
Host name |
IP Address |
Installing the Software |
Control host |
Node1 |
192.168.92.145 |
Ansible |
Managed hosts |
Node2 |
192.168.92.156 |
Managed hosts |
Node3 |
192.168.92.157 |
Getting ready: Shut down the three-node firewall and SELinux
systemctl stop firewalld.servicesystemctl disable firewalld.servicesetenforce 0
Start deployment: 1. Install Ansible (The following only operates on the control console)
# yum install epel-release -y //安装epel源# yum instlal ansible -y //安装ansible 软件包# ansible --version //查看ansible 版本信息# yum install tree -y # tree /etc/ansible //树状结构展示目录 /etc/ansible ├── ansible.cfg //ansible的配置文件├── hosts //ansible的主仓库,用于存储需要管理的远程主机的相关信息└── roles //角色
2. Configure Host Inventory
# vim /etc/ansible/hosts //配置主机清单[node2] //被管理主机分类192.168.92.156[node3] //被管理主机分类192.168.92.157
3. Set SSH login without password
# ssh-keygen -t rsa //生成密匙# ssh-copy-id [email protected] // 配置密匙对验证# ssh-copy-id [email protected] //配置密匙对验证
The deployment of the environment to this ansible is complete. The module is described in the next section.
Automated operation Koriyuki Detailed deployment Installation Ansible service (super Simple)