# debug output for task

**URL:** <https://forum.ansible.com/t/debug-output-for-task/27057>\
**Category:** Ansible Project\
**Created:** [March 20, 2018, 5:25pm UTC](https://forum.ansible.com/t/debug-output-for-task/27057 "2018-03-20T17:25:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cyberbob](https://avatars.discourse-cdn.com/v4/letter/c/45deac/32.png) [@Cyberbob](https://forum.ansible.com/u/Cyberbob)\
**Post date:** [March 20, 2018, 5:25pm UTC](https://forum.ansible.com/t/debug-output-for-task/27057/1 "2018-03-20T17:25:49Z")

</div>

Hi team,  
i have this playbook:

`

---

<div class="post-metadata">

**Author:** ![Cyberbob](https://avatars.discourse-cdn.com/v4/letter/c/45deac/32.png) [@Cyberbob](https://forum.ansible.com/u/Cyberbob)\
**Post date:** [March 21, 2018, 11:18am UTC](https://forum.ansible.com/t/debug-output-for-task/27057/2 "2018-03-21T11:18:54Z")

</div>

team,  
any ideas?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [March 22, 2018, 8:26pm UTC](https://forum.ansible.com/t/debug-output-for-task/27057/3 "2018-03-22T20:26:33Z")

</div>

> Hi team,  
> i have this playbook:
> 
> ---  
> - hosts: "{{ leaf\_name }}"  
> &nbsp;&nbsp;gather\_facts: no  
> &nbsp;&nbsp;connection: local
> 
> &nbsp;&nbsp;vars\_prompt:
> 
> &nbsp;&nbsp;- name: "leaf\_name"  
> &nbsp;&nbsp;&nbsp;&nbsp;prompt: "Enter switch hostname/ip"  
> &nbsp;&nbsp;&nbsp;&nbsp;private: no  
> &nbsp;&nbsp;- name: "vlan\_id"  
> &nbsp;&nbsp;&nbsp;&nbsp;prompt: "Enter access vlan for L2 ACCESS setup (example 10)"  
> &nbsp;&nbsp;&nbsp;&nbsp;private: no
> 
> &nbsp;&nbsp;vars:  
> &nbsp;&nbsp;&nbsp;&nbsp;cli:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;username: admin  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;password: password  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;transport: cli
> 
> &nbsp;&nbsp;tasks:
> 
> &nbsp;&nbsp;- name: Checking configuration for vlan {{ vlan\_id }}  
> &nbsp;&nbsp;&nbsp;&nbsp;ignore\_errors: true  
> &nbsp;&nbsp;&nbsp;&nbsp;nxos\_command:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;commands: show vlan id {{ vlan\_id }}  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;provider: "{{ cli }}"  
> &nbsp;&nbsp;&nbsp;&nbsp;register: output
> 
> &nbsp;&nbsp;- debug: var=output.stdout\_lines  
> &nbsp;&nbsp;- debug:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;msg="Looks like switch {{ leaf\_name }} has no vlan {{ vlan\_id }}."  
> &nbsp;&nbsp;&nbsp;&nbsp;when: output.stdout\_lines is not defined

output.stdout\_lines is always defined so this will never run.

> The questions is: i want to get output if van exist and get message "Looks  
> like switch {{ leaf\_name }} has no vlan {{ vlan\_id }}" if it doesn't.  
> What i must add to this playbook ?

Hard to say, I have never used the nxos\_command.  
It's always a good idea to provide the content of your output variable, because then you can get help from people that haven't used that module.
