1.4.1:ansible-doc 命令常见用法
1.4.1.1:列出所有可用模块
选项:
-l, --list
List available plugins
示例:
因为没有使用
-t
指定插件类别,这里列出的是默认类别的可用插件数量,而默认的插件类别是module,所以列出的就是所有可用模块。
[root@ansible ~]# ansible-doc -l
查看当前的模块数量:
[root@ansible ~]# ansible-doc -l | wc -l
3387
1.4.1.2:查看指定插件的使用帮助
用法:ansible-doc MOD_NAME
示例:
[root@ansible ~]# ansible-doc shell
1.4.1.3:查看指定插件支持的参数
选项:
-s, --snippet
Show playbook snippet for specified plugin(s)
示例:
[root@ansible ~]# ansible-doc -s shell
- name: Execute shell commands on targets
shell:
chdir: # Change into this directory before running the command.
cmd: # The command to run followed by optional arguments.
creates: # A filename, when it already exists, this step will *not* be run.
executable: # Change the shell used to execute the command. This expects an absolute path to the executable.
free_form: # The shell module takes a free form command to run, as a string. There is no actual parameter named 'free form'. See the examples on how to use this module.
removes: # A filename, when it does not exist, this step will *not* be run.
stdin: # Set the stdin of the command directly to the specified value.
stdin_add_newline: # Whether to append a newline to stdin data.
warn: # Whether to enable task warnings.
1.4.1.4:查看指定类型的插件(默认类型为module)
选项:
-t 'TYPE', --type 'TYPE'
Choose which plugin type (defaults to "module"). Available plugin types are : ('become', 'cache', 'callback', 'cliconf', 'connection', 'httpapi', 'inventory', 'lookup', 'net‐
conf', 'shell', 'module', 'strategy', 'vars')
-l, --list
List available plugins
示例,查看 connection 类型的插件有哪些:
[root@ansible ~]# ansible-doc -t connection -l
这里可以看出,在Ansible的概念中,Plugin包含Module,Module只是Plugin的一个类别。