On 20.03.2018 18:25, Cyberbob wrote:
Hi team,
i have this playbook:
---
- hosts: "{{ leaf_name }}"
gather_facts: no
connection: local
vars_prompt:
- name: "leaf_name"
prompt: "Enter switch hostname/ip"
private: no
- name: "vlan_id"
prompt: "Enter access vlan for L2 ACCESS setup (example 10)"
private: no
vars:
cli:
username: admin
password: password
transport: cli
tasks:
- name: Checking configuration for vlan {{ vlan_id }}
ignore_errors: true
nxos_command:
commands: show vlan id {{ vlan_id }}
provider: "{{ cli }}"
register: output
- debug: var=output.stdout_lines
- debug:
msg="Looks like switch {{ leaf_name }} has no vlan {{ vlan_id
}}."
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.
--
Kai Stian Olstad
--
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/14c3a669711cf3deca6e51ff2cff2c05%40olstad.com.
For more options, visit https://groups.google.com/d/optout.