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

Quick start ansible

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

Ansible use: self-google/ Baidu

Teach you to use ansible in 10 minutes.

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