Added ansible templating example

This commit is contained in:
Michele Cereda
2022-05-03 19:50:15 +02:00
parent 21d6be6329
commit 5694f9bbe4
2 changed files with 18 additions and 0 deletions

View File

@@ -2,6 +2,14 @@
- hosts: all - hosts: all
tasks: tasks:
- name: >-
Get the values of some special variables.
See https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
for the full list.
debug:
var: "{{ item }}"
with_items: ["ansible_local", "playbook_dir", "role_path"]
- name: >- - name: >-
Remove empty or false values from a list piping it to 'select()'. Remove empty or false values from a list piping it to 'select()'.
Returns ["string"] from ["", "string", 0, false]. Returns ["string"] from ["", "string", 0, false].

View File

@@ -50,6 +50,14 @@ ansible-galaxy remove namespace.role
## Templating ## Templating
```yaml ```yaml
- name: >-
Get the values of some special variables.
See https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
for the full list.
debug:
var: "{{ item }}"
with_items: ["ansible_local", "playbook_dir", "role_path"]
- name: >- - name: >-
Remove empty or false values from a list piping it to 'select()'. Remove empty or false values from a list piping it to 'select()'.
Returns ["string"] from ["", "string", 0, false]. Returns ["string"] from ["", "string", 0, false].
@@ -345,12 +353,14 @@ Use the `lookup()` plugin with the `env` option:
- [Roles] - [Roles]
- [Tests] - [Tests]
- [Special variables]
- [Automating Helm using Ansible] - [Automating Helm using Ansible]
- [Edit .ini file in other servers using Ansible PlayBook] - [Edit .ini file in other servers using Ansible PlayBook]
- [Yes and No, True and False] - [Yes and No, True and False]
[automating helm using ansible]: https://www.ansible.com/blog/automating-helm-using-ansible [automating helm using ansible]: https://www.ansible.com/blog/automating-helm-using-ansible
[roles]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html [roles]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_reuse_roles.html
[special variables]: https://docs.ansible.com/ansible/latest/reference_appendices/special_variables.html
[tests]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html [tests]: https://docs.ansible.com/ansible/latest/user_guide/playbooks_tests.html
[edit .ini file in other servers using ansible playbook]: https://syslint.com/blog/tutorial/edit-ini-file-in-other-servers-using-ansible-playbook/ [edit .ini file in other servers using ansible playbook]: https://syslint.com/blog/tutorial/edit-ini-file-in-other-servers-using-ansible-playbook/