Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

ios_template module doesnt render {% for %} correctly if iterating over nested list #3601

Description

@artgromov
ISSUE TYPE
  • Bug Report
COMPONENT NAME

ios_template module

ANSIBLE VERSION
ansible 2.2.0 (devel 56ba10365c) last updated 2016/05/05 09:00:05 (GMT +300)
  lib/ansible/modules/core: (detached HEAD 9db1233521) last updated 2016/05/04 17:31:47 (GMT +300)
  lib/ansible/modules/extras: (detached HEAD 675d778b50) last updated 2016/05/04 17:31:47 (GMT +300)
  config file = /home/admin/ansible.cfg
  configured module search path = Default w/o overrides
CONFIGURATION
[defaults]
inventory = hosts.cfg
host_key_checking = False
OS / ENVIRONMENT
[admin@ansible ~]$ cat /etc/redhat-release 
Fedora release 22 (Twenty Two)
[admin@ansible ~]$ uname -a
Linux ansible.ag.lab 4.3.4-200.fc22.x86_64 #1 SMP Mon Jan 25 13:37:15 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[admin@ansible ~]$ python --version
Python 2.7.10
SUMMARY

ios_template module doesnt render {% for %} correctly in template:

router ospf {{ospf.process}}
{% for i in ospf.passive_ifaces %}
 passive-interface {{i}}
{% endfor %}
 exit

{% for area in ospf.areas %}
    {% for iface in area.ifaces %}
interface {{iface}}
 ip ospf {{ospf.process}} area {{area.id}}
 exit
    {% endfor %}
{% endfor %}

if iterating over nested variable structure like this:

ospf:
  process: 1
  areas:
    - id: 0
      ifaces:
        - gi1
        - gi2
        - gi3
  passive_ifaces:
    - gi3
STEPS TO REPRODUCE
  1. get and install any Cisco IOS-XE router (my case: CSR1000V, X86_64_LINUX_IOSD-UNIVERSALK9-M, Version 15.4(2)S, RELEASE SOFTWARE (fc2)
  2. git clone https://github.com/artgromov/ansible_modules_core_issues_3601 to ansible host
  3. cd ansible_ios_module_issue
  4. ansible-playbook play-net.yml

I suppose that you may not need step 1 if you erase first tasks from playbook.

EXPECTED RESULTS

Expected debug output for each host:

ok: [10.1.10.33] => {
    "check": {
        "changed": true, 
        "responses": [
            "", 
            "", 
            "", 
            "", 
            "", 
            "", 
            ""
        ], 
        "updates": [
            "router ospf 1", 
            "passive-interface gi3", 
            "exit", 
            "interface gi1", 
            "ip ospf 1 area 0",
            "exit",
            "interface gi2", 
            "ip ospf 1 area 0",
            "exit",
            "interface gi3", 
            "ip ospf 1 area 0"
            "exit",
        ]
    }
}
ACTUAL RESULTS

The module missed some lines during render. Routers didn't get full config changes.

Current debug output for each host:

ok: [10.1.10.33] => {
    "check": {
        "changed": true, 
        "responses": [
            "", 
            "", 
            "", 
            "", 
            "", 
            "", 
            ""
        ], 
        "updates": [
            "router ospf 1", 
            "passive-interface gi3", 
            "exit", 
            "interface gi1", 
            "interface gi2", 
            "interface gi3", 
            "ip ospf 1 area 0"
        ]
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions