Ansible:任意のタスクから実行したり対話式でtaskを実行したり
Start and Step — Ansible Documentation
$ ansible-playbook hoge.yml --start-at='crond' --step
--start-at=
を使うと任意のnameから処理を実行できます。
--step
でステップ実行。
実行例
$ ansible-playbook hoge.yml --start-at='crond' --step PLAY [hoge] ************************************************************* Perform task: TASK: app : crond (N)o/(y)es/(c)ontinue: Perform task: TASK: app : crond (N)o/(y)es/(c)ontinue: ************************* Perform task: TASK: app : batch処理のセット (N)o/(y)es/(c)ontinue: y Perform task: TASK: app : batch処理のセット (N)o/(y)es/(c)ontinue: *** TASK [app : batch処理のセット] ********************************** ok: [hoge_testserver] Perform task: TASK: app : logrotate.d for httpd (N)o/(y)es/(c)ontinue: Perform task: TASK: app : logrotate.d for httpd (N)o/(y)es/(c)ontinue: ********* Perform task: TASK: app : logrotate.d for td-agent (N)o/(y)es/(c)ontinue: Perform task: TASK: app : logrotate.d for td-agent (N)o/(y)es/(c)ontinue: ****** Perform task: TASK: app : motdを配置 (N)o/(y)es/(c)ontinue: Perform task: TASK: app : motdを配置 (N)o/(y)es/(c)ontinue: *********************** Perform task: TASK: app : bash_profileを配置 (N)o/(y)es/(c)ontinue: Perform task: TASK: app : bash_profileを配置 (N)o/(y)es/(c)ontinue: *************** PLAY RECAP ********************************************************************* hoge_testserver : ok=1 changed=0 unreachable=0 failed=0
Ansible公式Docでは
http://docs.ansible.com/ansible/playbooks_startnstep.htmldocs.ansible.com
This will cause ansible to stop on each task, and ask if it should execute that task. Say you had a task called “configure ssh”, the playbook run will stop and ask:
Perform task: configure ssh (y/n/c):
となっていますが、ぼくの使用している環境version(2.1.0.0)では、Noがデフォルト(大文字のN)となっていてEnterでスキップ可能でした。
ansible始めるならおすすめです

- 作者: Lorin Hochstein,Sky株式会社玉川竜司
- 出版社/メーカー: オライリージャパン
- 発売日: 2016/04/16
- メディア: 大型本
- この商品を含むブログ (2件) を見る