Ansible Tutorial
We will consider the sample ansible playbook to sort the list of strings to learn the debugging skills in ansible.
- hosts: localhost connection: local gather_facts: no tasks: - name: initialize list of strings set_fact: list_values: ['2', '4', '1','9', '3'] - name: sort defined list set_fact: sorted_list_strings: "{{ list_values | sort }}" - name: Print the var debug: var: sorted_list_strings
We can use option -vvvvv to debug the tasks in any ansible playbook, below is the sample debugging details for above ansible playbook.
Output:
$ ansible-playbook sort_list_strings.yml -vvvvv ansible-playbook 2.9.1 config file = /etc/ansible/ansible.cfg configured module search path = ['/home/username/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/lib/python3.7/site-packages/ansible executable location = /usr/bin/ansible-playbook python version = 3.7.0 (default, Aug 30 2018, 14:32:33) [GCC 8.2.1 20180801 (Red Hat 8.2.1-2)] Using /etc/ansible/ansible.cfg as config file setting up inventory plugins host_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() method script declined parsing /etc/ansible/hosts as it did not pass its verify_file() method auto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method Parsed /etc/ansible/hosts inventory source with ini plugin [WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match 'all' Loading callback plugin default of type stdout, v2.0 from /usr/lib/python3.7/site-packages/ansible/plugins/callback/default.py PLAYBOOK: sort_list_strings.yml ********************************************************************************************************************************************* Positional arguments: sort_list_strings.yml verbosity: 5 connection: smart timeout: 10 become_method: sudo tags: ('all',) inventory: ('/etc/ansible/hosts',) forks: 5 1 plays in sort_list_strings.yml PLAY [localhost] ************************************************************************************************************************************************************ META: ran handlers TASK [initialize list of strings] ******************************************************************************************************************************************* task path: /home/jpalanis/sort_list_strings.yml:7 ok: [localhost] => { "ansible_facts": { "list_values": [ "2", "4", "1", "9", "3" ] }, "changed": false } TASK [sort defined list] **************************************************************************************************************************************************** task path: /home/jpalanis/sort_list_strings.yml:11 ok: [localhost] => { "ansible_facts": { "sorted_list_strings": [ "1", "2", "3", "4", "9" ] }, "changed": false } TASK [Print the var] ******************************************************************************************************************************************************** task path: /home/jpalanis/sort_list_strings.yml:15 ok: [localhost] => { "sorted_list_strings": [ "1", "2", "3", "4", "9" ] } META: ran handlers META: ran handlers PLAY RECAP ****************************************************************************************************************************************************************** localhost : ok=3 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
Ansible Tutorial
Privacy Policy | Copyright2020 - All Rights Reserved. | Contact us | Report website issues in Github | Facebook page | Google+ page