Created
March 10, 2021 02:43
-
-
Save heiwa4126/f11035e0cc208fabd7cb9f7013557f36 to your computer and use it in GitHub Desktop.
最初に1回、最後に1回なにかするAnsibleのplaybook. 各ホストからXMLファイルあつめて最後に集計する、みたいなときに使う。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- name: do anything at first and at last | |
hosts: hosts1 | |
become: false | |
gather_facts: false | |
tasks: | |
- name: at 1st | |
debug: | |
msg: "run only on {{ inventory_hostname }} at first" | |
changed_when: true # notifyはchangedでないと発生しないので | |
notify: last_one | |
run_once: true | |
- name: do something | |
debug: var=inventory_hostname | |
- name: do something again | |
debug: var=inventory_hostname | |
handlers: | |
- name: at last | |
listen: last_one | |
debug: | |
msg: "run only on {{ inventory_hostname }} at last" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
インベントリは
こんな感じのを書いとくとテストが楽。`