Ansible:命令說解

來源:本站原創 Linux 超過425 views圍觀 0條評論
[[email protected] ~]# ansible
Usage: ansible <host-pattern> [options]

Options:
  -a MODULE_ARGS, --args=MODULE_ARGS    模塊的參數,如果執行默認COMMAND的模塊,即是命令參數,如:“date”,"pwd"等等
                        module arguments    模塊參數
  -k, --ask-pass        ask for SSH password  登錄密碼,提示輸入SSH密碼而不是假設基于密鑰的驗證
  --ask-su-pass         ask for su password    su切換密碼
  -K, --ask-sudo-pass   ask for sudo password  提示密碼使用sudo,sudo表示提權操作
  --ask-vault-pass      ask for vault password
  -B SECONDS, --background=SECONDS     后臺運行超時時間
                        run asynchronously, failing after X seconds
                        (default=N/A)
  -C, --check           don't make any changes; instead, try to predict some    只是測試一下會改變什么內容,不會真正去執行;相反,試圖預測一些可能發生的變化
                        of the changes that may occur
  -c CONNECTION, --connection=CONNECTION   連接類型使用。可能的選項是paramiko(SSH),SSH和地方。當地主要是用于crontab或啟動。
                        connection type to use (default=smart)
  -f FORKS, --forks=FORKS   并行任務數。NUM被指定為一個整數,默認是5
                        specify number of parallel processes to use
                        (default=5)
  -h, --help            show this help message and exit   打開幫助文檔API
  -i INVENTORY, --inventory-file=INVENTORY    指定庫存主機文件的路徑,默認為/etc/ansible/hosts
                        specify inventory host file
                        (default=/etc/ansible/hosts)
  -l SUBSET, --limit=SUBSET    進一步限制所選主機/組模式  --limit=192.168.91.135 只對這個ip執行
                        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   執行模塊的名字,默認使用 command 模塊,所以如果是只執行單一命令可以不用 -m參數
                        module name to execute (default=command)
  -M MODULE_PATH, --module-path=MODULE_PATH    要執行的模塊的路徑,默認為/usr/share/ansible/
                        specify path(s) to module library
                        (default=/usr/share/ansible/)
  -o, --one-line        condense output      壓縮輸出,摘要輸出.嘗試一切都在一行上輸出。
  -P POLL_INTERVAL, --poll=POLL_INTERVAL    調查背景工作每隔數秒。需要- b
                        set the poll interval if using -B (default=15)
  --private-key=PRIVATE_KEY_FILE    私鑰路徑,使用這個文件來驗證連接
                        use this file to authenticate the connection
  -S, --su              run operations with su    用 su 命令
  -R SU_USER, --su-user=SU_USER      指定SU的用戶,默認是root用戶
                        run operations with su as this user (default=root)
  -s, --sudo            run operations with sudo (nopasswd)    
  -U SUDO_USER, --sudo-user=SUDO_USER    sudo到哪個用戶,默認為 root  
                        desired sudo user (default=root)
  -T TIMEOUT, --timeout=TIMEOUT    指定SSH默認超時時間,  默認是10S
                        override the SSH timeout in seconds (default=10)
  -t TREE, --tree=TREE  log output to this directory     將日志內容保存在該輸出目錄,結果保存在一個文件中在每臺主機上。
  -u REMOTE_USER, --user=REMOTE_USER    遠程用戶, 默認是root用戶
                        connect as this user (default=root)
  --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   輸出ansible的版本
 
 特殊說明:    
1. ansible是指令核心部分,其主要用于執行ad-hoc(點對點)命令,即單條命令。默認后面需要跟主機和選項部分,默認不指定模塊時,使用的是command模塊。      
2. 默認使用的模塊是可以在ansible.cfg 中進行修改的。 /etc/ansible/ansible.cfg  \
舉例:    [[email protected] ~]# ansible 192.168.91.137 -a 'pwd'192.168.91.137 | success | rc=0 >>/root
 
[[email protected] ~]# ansible-doc  -h
Usage: ansible-doc [options] [module...]

Show Ansible module documentation     顯示Ansible模塊文檔

Options:
  --version             show program's version number and exit    顯示ansible-doc的版本號
  -h, --help            show this help message and exit  顯示命令參數API文檔
  -M MODULE_PATH, --module-path=MODULE_PATH   查詢模塊,--module-path=MODULE_PATH  指定模塊的路徑
                        Ansible modules/ directory
  -l, --list            List available modules   顯示已存在的所有模塊列表
  -s, --snippet         Show playbook snippet for specified module(s)   顯示playbook制定模塊的用法
  -v                    Show version number and exit   顯示ansible-doc的版本號
 
舉例:      $     ansible-doc -l      $     ansible-doc -s command 3.ansible-galaxy   參數詳解:
 
 
[[email protected] ~]# ansible-galaxy -h
Usage: ansible-galaxy [init|info|install|list|remove] [--help] [options] ...

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

See 'ansible-galaxy <command> --help' for more information on a specific command.

  特殊說明:    ansible-galaxy 指令用于方便的從https://galaxy.ansible.com/ 站點下載第三方擴展模塊,我們可以形象的理解其類似于centos下的yum、python下的pip或easy_install  舉例:    [[email protected] ~]# ansible-galaxy install aeriscloud.docker – downloading role ‘docker’, owned by aeriscloud – extracting aeriscloud.docker to /etc/ansible/roles/aeriscloud.docker – aeriscloud.docker was installed successfully 4.ansible-playbook  參數詳解:

[[email protected] ~]# 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, try to predict some
                        of the changes that may occur
  -c CONNECTION, --connection=CONNECTION
                        connection type to use (default=smart)
  -D, --diff            when changing (small) files and templates, show the
                        differences in those files; works great with --check
  -e EXTRA_VARS, --extra-vars=EXTRA_VARS
                        set additional variables as key=value or YAML/JSON
  --force-handlers      run handlers even if a task fails
  -f FORKS, --forks=FORKS
                        specify number of parallel processes to use
                        (default=5)
  -h, --help            show this help message and exit
  -i INVENTORY, --inventory-file=INVENTORY
                        specify inventory host file
                        (default=/etc/ansible/hosts)
  -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
  --list-tasks          list all tasks that would be executed
  -M MODULE_PATH, --module-path=MODULE_PATH
                        specify path(s) to module library
                        (default=/usr/share/ansible/)
  --private-key=PRIVATE_KEY_FILE
                        use this file to authenticate the connection
  --skip-tags=SKIP_TAGS
                        only run plays and tasks whose tags do not match these
                        values
  --start-at-task=START_AT
                        start the playbook at the task matching this name
  --step                one-step-at-a-time: confirm each task before running
  -S, --su              run operations with su
  -R SU_USER, --su-user=SU_USER
                        run operations with su as 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 these values
  -T TIMEOUT, --timeout=TIMEOUT
                        override the SSH timeout 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 to enable
                        connection debugging)
  --version             show program's version number and exit

5.ansible-pull  參數詳解:

[[email protected] ~]# ansible-pull -h
Usage: ansible-pull [options] [playbook.yml]

Options:
  -K, --ask-sudo-pass   ask for sudo password    
  -C CHECKOUT, --checkout=CHECKOUT
                        branch/tag/commit to checkout.  Defaults to behavior
                        of repository module.
  -d DEST, --directory=DEST    
                        directory to checkout repository to
  -e EXTRA_VARS, --extra-vars=EXTRA_VARS
                        set additional variables as key=value or YAML/JSON
  -f, --force           run the playbook even if the repository could not be
                        updated
  -h, --help            show this help message and exit
  -i INVENTORY, --inventory-file=INVENTORY    指定庫存主機文件的路徑,默認為/etc/ansible/hosts
                        location of the inventory host file
  -m MODULE_NAME, --module-name=MODULE_NAME   從倉庫檢查的模塊名,默認是git
                        Module name used to check out repository.  Default is
                        git.
  -o, --only-if-changed   
                        only run the playbook if the repository has been
                        updated
  --purge               purge checkout after playbook run   
  -s SLEEP, --sleep=SLEEP
                        sleep for random interval (between 0 and n number of
                        seconds) before starting. this is a useful way to
                        disperse git requests
  -U URL, --url=URL     URL of the playbook repository
  --vault-password-file=VAULT_PASSWORD_FILE
                        vault password file
  -v, --verbose         Pass -vvvv to ansible-playbook

6.ansible-vault  參數詳解:

[[email protected] ~]# ansible-vault 
Usage: ansible-vault [create|decrypt|edit|encrypt|rekey] [--help] [options] file_name

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

See 'ansible-vault <command> --help' for more information on a specific command.

  特殊說明:官方博客。 7.參考資料  ansible中文權威指南: http://www.ansible.com.cn/  ansible小結(二):ansible結構:  http://ju.outofmemory.cn/entry/143179

文章出自:CCIE那點事 http://www.qdxgqk.live/ 版權所有。本站文章除注明出處外,皆為作者原創文章,可自由引用,但請注明來源。 禁止全文轉載。
本文標題:Ansible:命令說解
本文鏈接:http://www.qdxgqk.live/?p=3702轉載請注明轉自CCIE那點事
如果喜歡:點此訂閱本站
?
?
萌宠夺宝游戏 七乐彩走势图500期 时时彩组选缩水在线 贵州11选5任选遗漏 北京单场比分投注技巧 易发斗地主每天送6元 体育彩票分析系统 爱投网买彩票 十七岁应该怎么赚钱 北京赛车pk10免费计划 澳洲幸运5计划软件手机版下载 杰克棋牌官网完整版 大乐透前区7区分布图 什么个体行业好赚钱 河南11选5胆拖玩法 pk10牛牛是不是坑 房地产股票指数