-
Notifications
You must be signed in to change notification settings - Fork 48
Description
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
Ansible Version and collection version
ansible [core 2.16.0]
config file = /home/fake_domain/fake_user/ans-network-cloud/ansible.cfg
configured module search path = ['/home/fake_domain/fake_user/ans-network-cloud/modules']
ansible python module location = /home/fake_domain/fake_user/ans-network-cloud/.venv/lib64/python3.11/site-packages/ansible
ansible collection location = /home/fake_domain/fake_user/.ansible/collections:/usr/share/ansible/collections
executable location = /home/fake_domain/fake_user/ans-network-cloud/.venv/bin/ansible
python version = 3.11.11 (main, Dec 9 2024, 15:32:27) [GCC 8.5.0 20210514 (Red Hat 8.5.0-22)] (/home/fake_domain/fake_user/ans-network-cloud/.venv/bin/python3.11)
jinja version = 3.1.5
libyaml = True
DCNM version
- V 11.5.4
Affected module(s)
- dcnm_network
Ansible Playbook
---
- name: Deploy DCNM/NDFC configurations
hosts: "{{ group_run }}"
connection: httpapi
vars_prompt:
- name: group_run
prompt: |
Choose your datacenter:
cnb_ndfc
bp2_dcnm
sac_ndfc
tk2_ndfc
ban_ndfc
private: false
default: cnb_ndfc
- name: Attach bp2_v128-rd_vCloud23_10-9-128-0m22 to lfsw07 and lfsw08
cisco.dcnm.dcnm_network:
fabric: BP2_LAB
state: merged
config:
- net_name: bp2_v128-rd_vCloud23_10-9-128-0m22
vrf_name: RD
deploy: true
attach:
- ip_address: "{{ canos_lfsw07_list[0] }}"
ports:
- Port-channel509
- Port-channel510
deploy: true
- ip_address: "{{ canos_lfsw07_list[1] }}"
ports:
- Port-channel509
- Port-channel510
deploy: true
- ip_address: "{{ canos_lfsw08_list[0] }}"
ports:
- Ethernet103/1/23
- Ethernet103/1/24
- Ethernet103/1/25
- Ethernet103/1/26
- Ethernet103/1/27
- Ethernet103/1/28
deploy: true
- ip_address: "{{ canos_lfsw08_list[1] }}"
ports:
- Ethernet104/1/23
- Ethernet104/1/24
- Ethernet104/1/25
- Ethernet104/1/26
- Ethernet104/1/27
- Ethernet104/1/28
deploy: true
register: error
ignore_errors: true
Debug Output
Expected Behavior
config should be attached in DCNM according to ansible argspec
Actual Behavior
[{'networkName': 'bp2_v128-rd_vCloud23_10-9-128-0m22', 'lanAttachList': [{'tor_ports': None, 'fabric': 'BP2_LAB', 'networkName': 'bp2_v128-rd_vCloud23_10-9-128-0m22', 'serialNumber': 'FDO23191QGX', 'switchPorts': 'Port-channel509,Port-channel510', 'detachSwitchPorts': '', 'vlan': 128, 'dot1QVlan': 0, 'untagged': False, 'deployment': True, 'extensionValues': '', 'instanceValues': '', 'freeformConfig': '', 'torports': []}, {'tor_ports': None, 'fabric': 'BP2_LAB', 'networkName': 'bp2_v128-rd_vCloud23_10-9-128-0m22', 'serialNumber': 'FDO232009DB', 'switchPorts': 'Port-channel509,Port-channel510', 'detachSwitchPorts': '', 'vlan': 128, 'dot1QVlan': 0, 'untagged': False, 'deployment': True, 'extensionValues': '', 'instanceValues': '', 'freeformConfig': '', 'torports': []}]}]
<class 'str'>
Invalid JSON response: Unrecognized field "tor_ports" (class com.cisco.dcbu.vinci.rest.resources.topdown.LanAttach), not marked as ignorable
Steps to Reproduce
collect ansible temporary files from playbook run, extract the ZIP data from AnsiballZ_dcnm_network.py and unzip, insert the follow print statements:
here:
for attempt in range(0, 50):
resp = dcnm_send(self.module, method, attach_path, json.dumps(self.diff_attach))
update_in_progress = False
print(self.diff_attach)
print(type(resp["DATA"]))
print(resp["DATA"])
for key in resp["DATA"].keys(): ---------------------------traceback module error on this line of code: 'str' object has no attribute 'keys'
if re.search(r"Failed.*Please try after some time", str(resp["DATA"][key])):
update_in_progress = True
if update_in_progress:
time.sleep(1)
continue
produces the following:
print(self.diff_attach)------->[{'networkName': 'bp2_v128-rd_vCloud23_10-9-128-0m22', 'lanAttachList': [{'tor_ports': None, 'fabric': 'BP2_LAB', 'networkName': 'bp2_v128-rd_vCloud23_10-9-128-0m22', 'serialNumber': 'FDO23191QGX', 'switchPorts': 'Port-channel509,Port-channel510', 'detachSwitchPorts': '', 'vlan': 128, 'dot1QVlan': 0, 'untagged': False, 'deployment': True, 'extensionValues': '', 'instanceValues': '', 'freeformConfig': '', 'torports': []}, {'tor_ports': None, 'fabric': 'BP2_LAB', 'networkName': 'bp2_v128-rd_vCloud23_10-9-128-0m22', 'serialNumber': 'FDO232009DB', 'switchPorts': 'Port-channel509,Port-channel510', 'detachSwitchPorts': '', 'vlan': 128, 'dot1QVlan': 0, 'untagged': False, 'deployment': True, 'extensionValues': '', 'instanceValues': '', 'freeformConfig': '', 'torports': []}]}]
print(type(resp["DATA"]))-----><class 'str'>
print(resp["DATA"])--->Invalid JSON response: Unrecognized field "tor_ports" (class com.cisco.dcbu.vinci.rest.resources.topdown.LanAttach), not marked as ignorable
References
NOTE:
ANSIBLE_KEEP_REMOTE_FILES=1 doesn't work for saving locally generated/executed temp files. to make the hack work, you have to run the playbook to generate the local module._socket_path, while in a separate terminal, use a bash script to monitor the tmp/ directory/subdirectories where ansible is creating/storing the temp files, copy AnsiballZ_dcnm_network.py to the root playbook directory, extract the base64 encoded string assigned to ZIPDATA object and redirect to zipfile.zip, unzip to get the imports, insert print statements into the extracted dcnm_network.py module, save and rezip to newzip.zip with:
cat newzip.zip | base64 -w 0 >> /home/OTXLAB/dgiardin.lab/ans-network-cloud/collected_files/AnsiballZ_dcnm_network.py
then open the AnsiballZ_dcnm_network.py file with the newly appended base64 encoded string, replace value of ZIPDATA with new string, save&run 'python3 AnsiballZ_dcnm_networy.py to produce the output shown above. needs to be done before the local module._socket_path persistent connection timeout is reached.