Last active
August 1, 2019 02:25
-
-
Save madsonic/1b908998ea9cc432613695ebf050fb83 to your computer and use it in GitHub Desktop.
ansible tips and tricks
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
| # render template via ansible module | |
| $ ansible all -i "localhost," \ | |
| -c local \ | |
| -m template \ | |
| -a "src=test.txt.j2 dest=./test.txt" \ | |
| --extra-vars='{"users": ["Mike", "Smith", "Klara", "Alex"]}' | |
| # render template via playbook | |
| - hosts: 127.0.0.1 | |
| tasks: | |
| - name: Test jinja2template | |
| template: src=test.j2 dest=test.conf | |
| ansible-playbook jinja2test.yml --check --diff --connection=local | |
| # handle machine restarts/connection restart etc | |
| # if these tasks are handlers, let them listen to the same topic while having the | |
| # 'wait' task to be after the task responsible for the connection abortion | |
| - name: some task that will affect control machine to target host connection | |
| ... | |
| async: 1 # any value > 0 | |
| poll: 0 | |
| - name: wait for connection | |
| wait_for_connection: | |
| timeout: 60 | |
| delay: 2 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment