用法:
ansible <host-pattern> [options]
Options:
-a MODULE_ARGS, --args=MODULE_ARGS
module arguments
# 模块参数
--ask-vault-pass ask for vault password
#加密playbook文件时提示输入密码
-B SECONDS, --background=SECONDS
run asynchronously, failing after X seconds(default=N/A)
#后台运行任务超时时间,异步运行,X秒之后失败,终止任务
-C, --check don't make any changes; instead, try to predict some
of the changes that may occur
#模拟运行,测试什么内容会改变
-D, --diff when changing (small) files and templates, show the
differences in those files; works great with --check
#当更新的文件数及内容较少时,该选项可显示这些文件不同的地方,该选项结合-C用会有较好的效果
-e EXTRA_VARS, --extra-vars=EXTRA_VARS
set additional variables as key=value or YAML/JSON, if filename prepend with @
# 执行命令时添加额外参数变量
-f FORKS, --forks=FORKS
specify number of parallel processes to use (default=5)
#指定并发的任务数,默认为5
-h, --help show this help message and exit
#显示帮助
-i INVENTORY, --inventory=INVENTORY, --inventory-file=INVENTORY
specify inventory host path or comma separated host list. --inventory-file is deprecated
#指定inventory文件或者主机列表(用逗号分隔)
-l SUBSET, --limit=SUBSET
further limit selected hosts to an additional pattern
#指定运行的主机
--list-hosts outputs a list of matching hosts; does not execute anything else
#列出匹配的主机,不执行任何操作
-m MODULE_NAME, --module-name=MODULE_NAME
module name to execute (default=command)
#指定模块,默认为command
-M MODULE_PATH, --module-path=MODULE_PATH
prepend colon-separated path(s) to module library (default=~/.ansible/plugins/modules:/usr/share/ansible/plugins/modules)
#指定模块路径
-o, --one-line condense output
#压缩输出,标准输出至一行
--playbook-dir=BASEDIR
Since this tool does not use playbooks, use this as a substitute playbook directory.This sets the relative path for many features including roles/ group_vars/ etc.
#指定playbook目录路径
-P POLL_INTERVAL, --poll=POLL_INTERVAL
set the poll interval if using -B (default=15)
#定期返回后台任务进度
--syntax-check perform a syntax check on the playbook, but do not execute it
#对playbook进行语法检查,不执行
-t TREE, --tree=TREE log output to this directory
#输出信息至TREE目录下,结果文件以远程主机命名
--vault-id=VAULT_IDS the vault identity to use
--vault-password-file=VAULT_PASSWORD_FILES
vault password file
#
-v, --verbose verbose mode (-vvv for more, -vvvv to enable connection debugging)
#显示详情
--version show program's version number, config file location, configured module search path, module location,executable location and exit
#显示版本信息
Privilege Escalation Options:
control how and which user you become as on target hosts
-b, --become run operations with become (does not imply password prompting)
#
--become-method=BECOME_METHOD
privilege escalation method to use (default=sudo), use `ansible-doc -t become -l` to list valid choices.
#
--become-user=BECOME_USER
run operations as this user (default=root)
#
-K, --ask-become-pass
ask for privilege escalation password
#
Connection Options:
control as whom and how to connect to hosts
-k, --ask-pass ask for connection password
#认证密码
--private-key=PRIVATE_KEY_FILE, --key-file=PRIVATE_KEY_FILE
use this file to authenticate the connection
#指定密钥文件
-u REMOTE_USER, --user=REMOTE_USER
connect as this user (default=None)
#指定用户
-c CONNECTION, --connection=CONNECTION
connection type to use (default=smart)
#指定连接方式
-T TIMEOUT, --timeout=TIMEOUT
override the connection timeout in seconds(default=10)
#指定连接超时时间
--ssh-common-args=SSH_COMMON_ARGS
specify common arguments to pass to sftp/scp/ssh (e.g.ProxyCommand)
#ssh连接参数
--sftp-extra-args=SFTP_EXTRA_ARGS
specify extra arguments to pass to sftp only (e.g. -f,-l)
#sftp参数
--scp-extra-args=SCP_EXTRA_ARGS
specify extra arguments to pass to scp only (e.g. -l)
#scp参数
--ssh-extra-args=SSH_EXTRA_ARGS
specify extra arguments to pass to ssh only (e.g. -R)
#ssh参数
参考:
- ansible权威指南
- ansible命令