Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Sample code for installing Ansible under Centos

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Ansible

Ansible is a new automatic operation and maintenance tool. Based on Python development, it integrates the advantages of many operation and maintenance tools (puppet, cfengine, chef, func, fabric), and realizes the functions of batch system configuration, batch program deployment, batch running commands and so on.

Ansible works based on modules and does not have the ability to deploy in batches. What really has batch deployment is the module that ansible runs, and ansible only provides a framework. It mainly includes:

Connection plug-in connection plugins: responsible for communication with the monitored side; host inventory: the host that specifies the operation, is the host that is defined in the configuration file to monitor; core modules, command modules, custom modules; log mail and other functions with the help of plug-ins; playbook: when the script performs multiple tasks, it is not necessary to allow nodes to run multiple tasks at a time.

1.ansible deployment

The functions of ansible and saltstack are roughly the same, but the good thing is that our Ansible does not need a client. There is no Ansible package in Centos's yum source. We need to install Aliyun's epel source with RPM first:

Rpm-Uvh https://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpmyum install ansiable-y

2.ansible configuration

System environment:

Server:172.16.0.10 = > Centos 7.264-bit client1:172.16.0.11 = > Centos 6.764-bit client2:172.16.0.12 = > Centos 6.764-bit

Add client:

1. Profile parameters

Edit / etc/ansible/hosts

[webservers] # # alpha.example.org## beta.example.org172.16.0.11172.16.0.12

Edit / etc/ansible/ansible.cfg to resolve the following issues

Host_key_checking = False

The default ansible is authenticated using key. If you log in to the server with a password and use ansible, either change the ask_pass = True of the ansible.cfg configuration file to uncomment, or add-k when running the command, which means-k,-- ask-pass ask for SSH password. Modify it again: host_key_checking= False

two。 Use ansible to ping command

Whether the client is connected by a single test

[root@zabbix-server ~] # ansible 172.16.0.11-m ping-kSSH password: = = > enter the client password 172.16.0.11 | SUCCESS = > {"changed": false, "ping": "pong"} [root@zabbix-server ~] # ansible 172.16.0.12-m ping-kSSH password: 172.16.0.12 | SUCCESS = > {"changed": false, "ping": "pong"}

Test whether a group is connected or not

[root@zabbix-server ~] # ansible webservers-m ping-kSSH password: 172.16.0.11 | SUCCESS = > {"changed": false, "ping": "pong"} 172.16.0.12 | SUCCESS = > {"changed": false, "ping": "pong"}

The installation is complete. The above is the whole content of this article, I hope it will be helpful to your study, and I also hope that you will support it.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report