読者です 読者をやめる 読者になる 読者になる

ログってなんぼ

日々のメモです

Ansible:任意のタスクから実行したり対話式でtaskを実行したり

ansible infra

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):

引用元:Start and Step — Ansible Documentation はてなブックマーク - Start and Step — Ansible Documentation

となっていますが、ぼくの使用している環境version(2.1.0.0)では、Noがデフォルト(大文字のN)となっていてEnterでスキップ可能でした。

ansible始めるならおすすめです

初めてのAnsible

初めてのAnsible