Ansible
Ansible⚑
Usage⚑
Meta⚑
Run handlers (before): - meta: flush_handlers
Loops⚑
Looping over Subelements⚑
Useful when you have a list of dictionaries and you want to pick the same element from all of them.
with_subelements:
- "{{ some list }}"
- interesting_list_item
- flags:
skip_missing: yes
Command line⚑
Variables⚑
To provide variables directly from the command line: --extra-vars "version=1.23.45 other_variable=foo"
.
Facts⚑
ansible_user_id
Only gather facts when tag matches⚑
To speed up playbooks, disable gather_facts
. In the parts where this is requiered, you can use this approach:
- hosts: all
sudo: yes
gather_facts: False
pre_tasks:
- setup:
filter: ansible_*
roles:
- your_role_here
tags:
- tag1
This way ansible will only gather some facts and only if the tag matches (when run with the -t
option).
Debug⚑
Include tags ignored⚑
Example:
- import_tasks: db-setup.yml tags=db-setup
This tags are ignored if you skip them. Bug: github
could not find item['foo']
key in iterated item⚑
Solution: specify a third element in the with_subelements list called flags that is a dict and contains skip_missing: yes.
with_subelements:
- "{{ some list }}"
- interesting_list_item
- flags:
skip_missing: yes
Reference⚑
Usage⚑
- ansible-docs Jinja2 filters.
Modules⚑
Utilities⚑
- ansigenome Tool for calculating dependency graphs and more.
Vault⚑
Plugins⚑
Timing⚑
Displays tasks timing at the end of the playbook output.
To enable, add callback_whitelist = profile_tasks
to ansible.cfg.