ipspace / netlab

Making virtual networking labs suck less
https://netlab.tools
Other
457 stars 69 forks source link

[BUG] multiple Arista EOS template issues (vrf+evpn) #1283

Closed ssasso closed 3 months ago

ssasso commented 3 months ago

When running the integration test evpn/04-vxlan-central-routing.yml, trying to use cEOS as device for l2, I have this template error:

(running netlab initial -o -l l2 -vvv)

The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 1128, in do_template
    res = self.environment.concat(rf)
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/native_helpers.py", line 88, in ansible_concat
    return ''.join([to_text(v) for v in nodes])
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/native_helpers.py", line 88, in <listcomp>
    return ''.join([to_text(v) for v in nodes])
  File "<template>", line 33, in root
  File "/root/GIT_H/netlab/netsim/ansible/templates/vrf/eos.bgp.j2", line 91, in root
  File "/root/GIT_H/netlab/netsim/ansible/templates/vrf/eos.bgp.j2", line 89, in t_6
  File "/usr/local/lib/python3.8/dist-packages/jinja2/runtime.py", line 857, in _fail_with_undefined_error
    raise self._undefined_exception(self._undefined_message)
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'af'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/ansible/plugins/action/template.py", line 138, in run
    resultant = templar.do_template(template_data, preserve_trailing_newlines=True, escape_backslashes=False)
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 1162, in do_template
    raise AnsibleUndefinedVariable(e)
ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 'af'
fatal: [l2 -> localhost]: FAILED! => changed=false
  msg: 'AnsibleUndefinedVariable: ''dict object'' has no attribute ''af'''

despite the reported line number, my initial guess is that the error is here:

https://github.com/ipspace/netlab/blob/fccaa40689d3c7db93343270f5ba93f3c264b450/netsim/ansible/templates/vrf/eos.bgp.j2#L24

the struct has no af attribute on the nodes l1 and l2.

I tried to change it to {% for af in ['ipv4','ipv6'] if af in vdata.af|default({}) %}

and then I moved forward but I got an error on the evpn template

TASK [Create evpn configuration] *************************************************************************************************************************************************************************************************
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: dict object has no element {'ipv4': True}
fatal: [l2 -> localhost]: FAILED! => changed=false
  msg: 'AnsibleUndefinedVariable: dict object has no element {''ipv4'': True}'
The full traceback is:
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 1128, in do_template
    res = self.environment.concat(rf)
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/native_helpers.py", line 88, in ansible_concat
    return ''.join([to_text(v) for v in nodes])
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/native_helpers.py", line 88, in <listcomp>
    return ''.join([to_text(v) for v in nodes])
  File "<template>", line 52, in root
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 268, in wrapper
    ret = func(*args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 647, in _ansible_finalize
    return thing if _fail_on_undefined(thing) is not None else ''
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 619, in _fail_on_undefined
    elif is_sequence(data):
  File "/usr/local/lib/python3.8/dist-packages/ansible/module_utils/common/collections.py", line 94, in is_sequence
    if not include_strings and is_string(seq):
  File "/usr/local/lib/python3.8/dist-packages/jinja2/runtime.py", line 857, in _fail_with_undefined_error
    raise self._undefined_exception(self._undefined_message)
jinja2.exceptions.UndefinedError: dict object has no element {'ipv4': True}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/ansible/plugins/action/template.py", line 138, in run
    resultant = templar.do_template(template_data, preserve_trailing_newlines=True, escape_backslashes=False)
  File "/usr/local/lib/python3.8/dist-packages/ansible/template/__init__.py", line 1162, in do_template
    raise AnsibleUndefinedVariable(e)
ansible.errors.AnsibleUndefinedVariable: dict object has no element {'ipv4': True}
fatal: [l2 -> localhost]: FAILED! => changed=false
  msg: 'AnsibleUndefinedVariable: dict object has no element {''ipv4'': True}'

but honestly I have no idea where that element came from... :(

ssasso commented 3 months ago

When running the original https://github.com/ipspace/netlab/blob/dev/tests/integration/evpn/04-vxlan-central-routing.yml test, I have:

TASK [eos_config: deploying evpn from /root/GIT_H/netlab/netsim/ansible/templates/evpn/eos.j2] ***********************************************************************************************************************************
fatal: [l1]: FAILED! => changed=false
  msg: 'dict object has no element {''ipv4'': True}'
fatal: [spine]: FAILED! => changed=false
  msg: 'dict object has no element {''ipv4'': True, ''vpnv4'': True}'
ipspace commented 3 months ago

Confirmed, it fails the evpn/01-vxlan-bridging.yml test as well.

Will fix, thank you!

ipspace commented 3 months ago

Should be fixed by 4015a7e270f07dbe01205f160d67786a6c2d2ee3 -- all the integration tests passed (can't tell you how glad I am to have them ;)