Hi All,
It seems like issues along these lines have been raised as bugs and closed several times... see
https://github.com/ansible/ansible/issues/17500I have created a role, which I intend to skip under certain circumstances. When the role is skipped, all tasks still run... OK... I don't understand why this is desired behavior but that's beside the point. I have ended up needing to put some very nasty looking "|default()" filters inside of my "with_items" clauses to get the playbook to run. Without the default values I end up with errors like 'dict object' has no attribute 'stdout_lines'
Any other suggestions? I guess I can have different playbooks for different roles rather than skipping roles that I don't want to use, but it seems a little cumbersome.
Thanks,
Paul
---
- name: "create_ironware : Gather information from router"
ironware_command:
commands:
- "show mpls vll detail | i ^VLL"
- "show vlan {{ port }}"
- "show version"
provider: "{{ cli }}"
register: ironware_checks
- name: "create_ironware : Process VLL information"
set_fact:
router_vlls: "{{ router_vlls | default([]) + [ item ] }}"
with_items: "{{
(ironware_checks.stdout_lines|default([[],[],[]]))[0]|map('regex_replace',
'^VLL (.+), VC-ID ([0-9]+),.*', 'name: \\1\\nid:
\\2')|map('from_yaml')|list }}"
- name: "create_ironware : Process VLAN information"
set_fact:
port_vlans: "{{ port_vlans | default([]) + [ item ] }}"
with_items: "{{
(ironware_checks.stdout_lines|default([[],[],[]]))[1]|map('regex_replace',
'.*VLAN: *([0-9]+) *(Tagged|Untagged).*', 'id: \\1\\ntagging:
\\2')|map('from_yaml')|list }}"