diff --git a/ansible/templating-tests.yml b/ansible/templating-tests.yml index 6893897..18bd3c1 100644 --- a/ansible/templating-tests.yml +++ b/ansible/templating-tests.yml @@ -2,6 +2,14 @@ - hosts: all 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: >- Remove empty or false values from a list piping it to 'select()'. Returns ["string"] from ["", "string", 0, false]. diff --git a/knowledge base/ansible.md b/knowledge base/ansible.md index 25af8e9..5956765 100644 --- a/knowledge base/ansible.md +++ b/knowledge base/ansible.md @@ -50,6 +50,14 @@ ansible-galaxy remove namespace.role ## Templating ```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: >- Remove empty or false values from a list piping it to 'select()'. Returns ["string"] from ["", "string", 0, false]. @@ -345,12 +353,14 @@ Use the `lookup()` plugin with the `env` option: - [Roles] - [Tests] +- [Special variables] - [Automating Helm using Ansible] - [Edit .ini file in other servers using Ansible PlayBook] - [Yes and No, True and False] [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 +[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 [edit .ini file in other servers using ansible playbook]: https://syslint.com/blog/tutorial/edit-ini-file-in-other-servers-using-ansible-playbook/