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

Installation and use of ansible

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

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:

(1) connection plug-in connection plugins: responsible for communicating with the monitored end

(2), host inventory: specify the host for operation, which is the host for monitoring defined in the configuration file.

(3) various modules core module, command module, custom module

(4) with the help of plug-ins, log mail and other functions are completed.

(5), playbook: when the script performs multiple tasks, it is not necessary to let the node run multiple tasks at one time.

You only need to install ansible on the server to use

Yum install ansible- y # check the ansible version yum info ansible# to see which modules are available ansible-doc-l

Installation and program environment

Program:

Ansible

Ansible-playbook

Ansible-doc

Configuration file:

/ etc/ansible/ansible.cfg

Host list

/ etc/ansible/hosts

Plug-in directory:

/ usr/share/ansible_plugins/

Commonly used commands

Prerequisites: 1. Do a good job of confidentiality. 2. Define the corresponding host information in / etc/ansible/hosts.

# copy local files to the corresponding host ansible host group-m copy-a "src=$ local path dest=$ remote host path" # execute the command ansible hosts group-m shell-a "/ usr/bin/ifconfig" on the remote host to write a simple playbook

Prerequisites: 1. No need to keep secret, no need to define host information. 2. Be familiar with playbook syntax.

Create a hosts file and record the hosts information

[ceshi] 192.168.200.160 ansible_connection=ssh ansible_username=root ansible_port=22 ansible_ssh_pass=123456

Check to obtain the target host information through the shell module:

-hosts: ceshi remote_user: root tasks:-name: ip shell: / usr/sbin/ifconfig & > > / var/log/messages

The implementation results are as follows:

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