Ansible Ad-Hoc command (3)

1. Introduction to Ad-Hoc

  1. Understand what is Ad-Hoc?

    Ad-Hoc is actually a set of commands run based on Ansible. Some are similar to the shell commands typed in the terminal. Ansible provides two ways to run and complete tasks, one is Ansible Ad-Hoc, the other is Ansible Playbook, and Ad-Hoc Hoc is mainly relative to Ansible Playbook, somewhat similar to the relationship between shell and shell script.

  2. What are the main functions of Ad-Hoc?

    Ad-Hoc mainly completes some simple scenarios and does not require too many operation steps. Basically, the tasks that can be completed every time the Ad-Hoc command is executed. For example, we need to check the ports that each server starts. At this time, we should not write a lot. The operation only needs to be completed through an Ad-Hoc command;

ansible all -m shell -a 'netstat -tnlp'

 execute command line result set

2. Ad-Hoc command module

  Above we understand what Ad-Hoc commands are, let's see what command modules Ad-Hoc has.

  1. View currently supported modules (currently I am using Ansible 2.4.2.0)

ansible-doc -l

  At present, it is not fully counted that Ansible supports more than 1370 modules in version 2.4, while more than 1600 modules are supported in Ansible version 2.5. For details, please refer to the official website help information (http://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html )

  2. After knowing the module name, you can ansible-doc -s to see which parameters of the module can be used;

ansible-doc -s module name

  3. Ansible common modules

 Ansible comes with a lot of modules. Compared with our normal situation, we only need to understand common modules.

1    ping module 
 2    raw module 
 3    yum module  
 4    pip module 
 5    synchronize module 
 6    template module 
 7    copy module 
 8    user module
 9    group module 
 10    service module 
 11    get_url module  
 12    file module 
 13    unarchive module 
 14    command module
 15    shell module
 16    cron module

  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324874939&siteId=291194637