ansible-playbook命令

Ansible-playbook是日常应用中使用频率最高的工具,其工作机制是通过读取预先编写好的playbook文件实现批量管理,要实现的功能和命令ansible是一样的,可以理解为按一定条件组成的ansible任务集。

ansible-playbook命令后跟YML格式的playbook文件执行事先编排好的任务集命令使用方式如下

ansible-playbook playbook.yml

具体示例如下

//执行gw.yml这个playbook中定义的所有任务集

ansible-playbook gw.yml

Playbook具有编写简单、可定制性高、灵活方便同时可固化日常所有操作的特点运维熟练掌握。

 

 

[root@localhost~]# ansible-playbook -h

Usage:ansible-playbook playbook.yml

 

Options:

  -k, --ask-pass        ask for SSH password

  --ask-su-pass         ask for su password

  -K, --ask-sudo-pass   ask for sudo password

  --ask-vault-pass      ask for vault password

  -C, --check           don't make any changes; instead, tryto predict some

                        of the changes that mayoccur

  -c CONNECTION, --connection=CONNECTION

                        connection type to use(default=smart)

  -D, --diff            when changing (small) files and templates,show the

                        differences in thosefiles; works great with --check

  -e EXTRA_VARS, --extra-vars=EXTRA_VARS

                        set additionalvariables as key=value or YAML/JSON

  --force-handlers      run handlers even if a task fails

  -f FORKS, --forks=FORKS

                        specify number ofparallel processes to use

                        (default=5)

  -h, --help            show this help message and exit

  -i INVENTORY, --inventory-file=INVENTORY

                        specify inventory hostfile

                       (default=/etc/ansible/hosts)

  -l SUBSET, --limit=SUBSET

                        further limit selectedhosts to an additional pattern

  --list-hosts          outputs a list of matching hosts; does notexecute

                        anything else

  --list-tasks          list all tasks that would be executed

  -M MODULE_PATH, --module-path=MODULE_PATH

                        specify path(s) tomodule library

                       (default=/usr/share/ansible/)

  --private-key=PRIVATE_KEY_FILE

                        use this file toauthenticate the connection

  --skip-tags=SKIP_TAGS

                        only run plays andtasks whose tags do not match these

                        values

  --start-at-task=START_AT

                        start the playbook atthe task matching this name

  --step                one-step-at-a-time: confirmeach task before running

  -S, --su              run operations with su

  -R SU_USER, --su-user=SU_USER

                        run operations with suas this user (default=root)

  -s, --sudo            run operations with sudo (nopasswd)

  -U SUDO_USER, --sudo-user=SUDO_USER

                        desired sudo user(default=root)

  --syntax-check        perform a syntax check on the playbook,but do not

                        execute it

  -t TAGS, --tags=TAGS  only run plays and tasks tagged with thesevalues

  -T TIMEOUT, --timeout=TIMEOUT

                        override the SSHtimeout in seconds (default=10)

  -u REMOTE_USER, --user=REMOTE_USER

                        connect as this user(default=root)

  --vault-password-file=VAULT_PASSWORD_FILE

                        vault password file

  -v, --verbose         verbose mode (-vvv for more, -vvvv toenable

                        connection debugging)

  --version             show program's version number andexit

 

 

分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS