Hi Pranay, if i use the package_status.results as "as below "in my play book, and the output is as below but what we need a is clean message " Package < pakage name> Missing".
*Error:* TASK [debug] *********************************************************************************************************************************************************** fatal: [we1t1te02003p]: FAILED! => {"msg": "'package_status' is undefined"} *Play Book* --- - hosts: all become: true become_method: sudo gather_facts: no vars_files: - "/home/ansible/.ansible/target.yml" tasks: - name: Check the required OS Packages are installed shell: /usr/bin/zypper -q search -is {{ item.pname }} warn=no with_items: - { pname: '"bing"'} - { pname: '"bonnie"' } register: package_status * - debug: msg="Package {{ item.item.pname }} Missing"* * with_items: "{{ package_status.results }}"* failed_when: package_status.rc != 0 changed_when: false ignore_errors: True tags: package On Monday, May 28, 2018 at 3:05:33 AM UTC+8, Pranay Nanda wrote: > > Use package_status.results > > > https://stackoverflow.com/questions/37925282/iteration-using-with-items-and-register > > On Monday, 28 May 2018 00:32:17 UTC+5:30, Vino B wrote: >> >> Hi All >> >> Request your help on where to put the debug statement >> >> Requirement 1: >> If a package is missing the output should be like "Package {{ package >> name }} missing" >> >> When debug is used the task name does not display instead the task is >> named as "debug" >> >> TASK[Check the required OS Packages are installed] is not displayed when >> using debug >> TASK [debug] Display this as a task name >> >> >> Play Book >> --- >> - hosts: all >> become: true >> become_method: sudo >> gather_facts: no >> vars_files: >> - "/home/ansible/.ansible/target.yml" >> tasks: >> >> - name: Check the required OS Packages are installed >> shell: /usr/bin/zypper -q search -is {{ item.pname }} warn=no >> with_items: >> - { pname: '"bing"'} >> - { pname: '"bonnie"' } >> register: package_status >> failed_when: package_status.rc != 0 >> changed_when: false >> ignore_errors: True >> tags: package >> >> -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/42edbf5a-82b3-469f-b541-cb1fe4cafd91%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.