ansible是新出现的自动化运维工具,基于Python开发,集合了众多运维工具(puppet、cfengine、chef、func、fabric)的优点,实现了批量系统配置、批量程序部署、批量运行命令等功能。
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 #执行命令时添加额外参数变量 -f FORKS, --forks=FORKS #specify number of parallel processes to use(default=5) #并行任务数。FORKS被指定为一个整数,默认是5 -h, --help #show this help message and exit #打开帮助文档API -i INVENTORY, --inventory-file=INVENTORY #specify inventory host path(default=/etc/ansible/hosts) or comma separated host list. #指定要读取的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 #specify path(s) to module library (default=None) #要执行的模块的路径 --new-vault-password-file=NEW_VAULT_PASSWORD_FILE #new vault password file for rekey # -o, --one-line #condense output #压缩输出,摘要输出.尝试一切都在一行上输出 --output=OUTPUT_FILE #output file name for encrypt or decrypt; use - for stdout # -P POLL_INTERVAL, --poll=POLL_INTERVAL #set the poll interval if using -B (default=15) #设置轮询间隔,每隔数秒。需要- B --syntax-check #perform a syntax check on the playbook, but do not execute it #检查Playbook中的语法书写 -t TREE, --tree=TREE #log output to this directory #将日志内容保存在该输出目录,结果保存在一个文件中在每台主机上 --vault-password-file=VAULT_PASSWORD_FILE #vault password file # -v, --verbose #verbose mode (-vvv for more, -vvvv to enable connection debugging) #执行详细输出 --version #show program's version number and exit #显示版本 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) #指定远程主机以USERNAME运行命令 -c CONNECTION, --connection=CONNECTION #connection type to use (default=smart) #指定连接方式,可用选项paramiko (SSH)、ssh、local,local方式常用于crontab和kickstarts -T TIMEOUT, --timeout=TIMEOUT #override the connection timeout in seconds(default=10) #SSH连接超时时间设定,默认10s --ssh-common-args=SSH_COMMON_ARGS #specify common arguments to pass to sftp/scp/ssh (e.g.ProxyCommand) # --sftp-extra-args=SFTP_EXTRA_ARGS #specify extra arguments to pass to sftp only (e.g. -f, -l) # --scp-extra-args=SCP_EXTRA_ARGS #specify extra arguments to pass to scp only (e.g. -l) # --ssh-extra-args=SSH_EXTRA_ARGS #specify extra arguments to pass to ssh only (e.g. -R) # Privilege Escalation Options: control how and which user you become as on target hosts -s, --sudo #run operations with sudo (nopasswd) (deprecated, use become) #相当于Linux系统下的sudo命令 -U SUDO_USER, --sudo-user=SUDO_USER #desired sudo user (default=root) (deprecated, use become) #使用sudo,相当于Linux下的sudo命令 -S, --su #run operations with su (deprecated, use become) # -R SU_USER, --su-user=SU_USER #run operations with su as this user (default=root) (deprecated, use become) # -b, --become #run operations with become (does not imply password prompting) # --become-method=BECOME_METHOD #privilege escalation method to use (default=sudo),valid choices: [ sudo | su | pbrun | pfexec | doas |dzdo | ksu | runas ] # --become-user=BECOME_USER #run operations as this user (default=root) # --ask-sudo-pass #ask for sudo password (deprecated, use become) # --ask-su-pass #ask for su password (deprecated, use become) # -K, --ask-become-pass #ask for privilege escalation password