Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rule to ensure switch nodes are defined when referenced by vPC Peer #232

Open
robvand opened this issue Nov 20, 2024 · 0 comments
Open
Assignees
Labels
bug Something isn't working

Comments

@robvand
Copy link

robvand commented Nov 20, 2024

Ansible Version

❯ ansible --version
ansible [core 2.16.3]
  config file = /Users/robvand/Code/cml/ndfc-evpn/nac-vxlan/ansible.cfg
  configured module search path = ['/Users/robvand/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/robvand/Code/cml/ndfc-evpn/nac-vxlan/collections/ansible_collections
  executable location = /Users/robvand/.pyenv/versions/nac-ndfc/bin/ansible
  python version = 3.10.3 (main, Nov 19 2024, 09:11:49) [Clang 16.0.0 (clang-1600.0.26.4)] (/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/bin/python)
  jinja version = 3.1.4
  libyaml = True

Ansible Collection Versions

Collection         Version
------------------ -------
ansible.netcommon  5.3.0  
ansible.posix      1.5.4  
ansible.utils      2.11.0 
cisco.dcnm         3.6.0  
cisco.nac_dc_vxlan 0.3.0  
cisco.nxos         5.3.0  
community.general  8.5.0

Cisco NDFC Version

ND Version 3.2(1i)
Fabric Controller Version 12.2.2.241

Cisco NX-OS Version

N/A

Which role is this issue related to?

cisco.nac_dc_vxlan.validate

Which section of the data model is this issue related to?

vxlan.topology

Expected Behavior

If user creates vPC peer with nodes that are not defined in vxlan.topology.switches the playbook should fail indicating that the switch nodes referenced by the vPC peer configuration are not defined.

Actual Behavior

Rule 305 does not prevent referencing non existing switch nodes. Role_create will fail.

TASK [cisco.nac_dc_vxlan.common : Build vPC Peering] ****************************************************************************************************************
Wednesday 20 November 2024  09:16:39 +0100 (0:00:00.008)       0:00:10.266 **** 
Wednesday 20 November 2024  09:16:39 +0100 (0:00:00.008)       0:00:10.266 **** 
An exception occurred during task execution. To see the full traceback, use -vvv. The error was: ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 's1-leaf-103'. 'dict object' has no attribute 's1-leaf-103'
fatal: [nac-ndfc1 -> localhost]: FAILED! => {"changed": false, "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 's1-leaf-103'. 'dict object' has no attribute 's1-leaf-103'"}

Ansible Playbook

Inventory file:

---
vxlan:
  topology:
    vpc_peers:
      - peer1: s1-leaf-103
        peer2: s1-leaf-108
        domain_id: 2
        peer1_peerlink_interfaces: 
        - name: eth1/6
        peer2_peerlink_interfaces:
        - name: eth1/6

Steps to Reproduce

ansible-playbook -i inventory.yaml vxlan.yaml --tags role_validate,role_create

Relevant Debug Output

The full traceback is:
Traceback (most recent call last):
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible/template/__init__.py", line 1010, in do_template
    res = myenv.concat(rf)
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible/template/native_helpers.py", line 83, in ansible_concat
    return ''.join([to_text(v) for v in nodes])
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible/template/native_helpers.py", line 83, in <listcomp>
    return ''.join([to_text(v) for v in nodes])
  File "<template>", line 34, in root
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible/template/__init__.py", line 295, in wrapper
    ret = func(*args, **kwargs)
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible/template/__init__.py", line 558, in _ansible_finalize
    return thing if _fail_on_undefined(thing) is not None else ''
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible/template/__init__.py", line 530, in _fail_on_undefined
    elif is_sequence(data):
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible/module_utils/common/collections.py", line 94, in is_sequence
    if not include_strings and is_string(seq):
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-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 's1-leaf-103'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible/plugins/action/template.py", line 152, in run
    resultant = templar.do_template(template_data, preserve_trailing_newlines=True, escape_backslashes=False, overrides=overrides)
  File "/Users/robvand/.pyenv/versions/3.10.3/envs/nac-ndfc/lib/python3.10/site-packages/ansible/template/__init__.py", line 1044, in do_template
    raise AnsibleUndefinedVariable(e, orig_exc=e)
ansible.errors.AnsibleUndefinedVariable: 'dict object' has no attribute 's1-leaf-103'. 'dict object' has no attribute 's1-leaf-103'
fatal: [nac-ndfc1 -> localhost]: FAILED! => {
    "changed": false,
    "msg": "AnsibleUndefinedVariable: 'dict object' has no attribute 's1-leaf-103'. 'dict object' has no attribute 's1-leaf-103'"
}
@robvand robvand added the bug Something isn't working label Nov 20, 2024
@mtarking mtarking self-assigned this Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants