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

What are the common methods of ansible

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces what the common methods of ansible have related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe you will have some gains after reading this article on common methods of ansible, let's take a look at it.

1. Ansible has many modules and many ways to write playbook, but I personally feel that there is no need to be so troublesome. As long as I master the following modules, it will be enough.

First, take a look at the common host list configuration:

[wangsn@m-ubonex-jenkins] $ansible-I / etc/ansible/hosts twm-m shell-a "ls-l / opt"-- sudo-k

Parameter description:

-I: specify the location of the host manifest file

-m: specify the name of the module. Commonly used modules include shell module, copy module, cron module, etc.

-a: specify the parameters of the module

2. Copy module

Purpose: copy files to a remote host

Example:

[wangsn@m-ubonex-jenkins ~] $ansible-I / etc/ansible/hosts twm-m script-a'/ home/wangsn/useradd.sh'-- sudo-k [wangsn@m-ubonex-jenkins ~] $ansible-I / etc/ansible/hosts twm-m cron-a 'name= "test" minute= "0" hour= "5L2" job= "ls-alh > / dev/null"-sudo-k [wangsn@m-ubonex-jenkins ~] $ansible-I / etc/ Ansible/hosts twm-m cron-a 'name= "test" state=absent'-- sudo-k-Delete scheduled tasks

5. Fetch module (pull files)

Function: the file pull module mainly copies the files from the remote host to the local machine, which is the opposite of the function of the copy module.

Example:

[wangsn@m-ubonex-jenkins] $ansible-I / etc/ansible/hosts twm-m fetch-a "src=/opt/apache-tomcat-8.0.27 dest=/home/wangsn"-- sudo-k

Parameter description:

Src represents the file path that needs to be transferred on the remote host

Dest is represented as a path on the local machine.

The files transferred are classified according to the IP address, and then the path is the path of the source file.

Note: when pulling files, you must pull files, not folders.

This is the end of the article on "what are the common methods of ansible?" Thank you for reading! I believe you all have a certain understanding of "what are the common methods of ansible". If you want to learn more, you are welcome to follow the industry information channel.

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

Internet Technology

Wechat

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

12
Report