I used this extensively in the past and verified this worked as expected, but somewhere along the line this has been broken.
SUMMARY
community.network.nclu.commands module fails to function when the commands being passed to the module is using a loop mechanism.
I have confirmed using with_items and also lines from a file with_lines.
Working Example:
tasks:
- name: Add config example
community.network.nclu:
commands:
- add hostname leaf0-prod
- add bond peerlink bond slaves swp16
- add bond peerlink bond mode 802.3ad
- add bond peerlink mtu 9216
- add bond peerlink bond slaves swp32
- add bond peerlink bond mode 802.3ad
- add bond peerlink mtu 9216
Broken Example:
- name: iterate nclu commands
community.network.nclu:
commands:
"{{item}}"
with_lines: cat "{{ config_file }}"
when: item | length > 1
Error Output:
failed: [host] (item=add bond peerlink bond slaves swp16) => {"ansible_loop_var": "item", "changed": false, "item": "add bond peerlink bond slaves swp16", "msg": "Error in pending config. You may want to view `net pending` on this target."}
ISSUE TYPE
Bug Report
COMPONENT NAME
Cumulus Linux NCLU Commands Module
ANSIBLE VERSION
Ansible Versions:
ansible [core 2.12.1]
python version = 3.10.1 (main, Dec 18 2021, 23:53:45) [GCC 11.1.0]
jinja version = 3.0.3
libyaml = True
COLLECTION VERSION
-->
community.network 3.1.0
CONFIGURATION
No Output
OS / ENVIRONMENT
Cumulus Linux 4.0
STEPS TO REPRODUCE
Steps to reproduce can be performed using any looping with nclu commands module.
Working playbook
---
- name: Generate, Assemble and Config to Cumulus devices, default with no action
hosts:
- cumulus
become: True
gather_facts: yes
vars:
file_name: all_config
playbook_name: all-settings.yml
vars_prompt:
- name: vars_prompt_username
prompt: "Enter your Cumulus username ?"
private: no
tasks:
- name: Add Config
community.network.nclu:
commands:
- add bond peerlink bond slaves swp16
- add bond peerlink bond mode 802.3ad
- add bond peerlink mtu 9216
- add bond peerlink bond slaves swp32
- add bond peerlink bond mode 802.3ad
- add bond peerlink mtu 9216
- add bond comp0-bm-bond bond slaves swp11
- add bond comp0-bm-bond clag id 11
- add bond comp0-bm-bond bond mode 802.3ad
- add bond comp0-bm-bond bridge vids 15-18
- add bond comp0-bm-bond mtu 9000
Broken PlayBook:
---
- name: Generate, Assemble and Config to Cumulus devices, default with no action
remote_user: cumulus
hosts:
- cumulus
become: True
roles:
- { role: local_build, tags: [ always ] }
- nclu
connection: local
gather_facts: yes
vars:
file_name: all_config
playbook_name: all-settings.yml
file:
- add bond peerlink bond slaves swp16
- add bond peerlink bond mode 802.3ad
- add bond peerlink mtu 9216
- add bond peerlink bond slaves swp32
- add bond peerlink bond mode 802.3ad
- add bond peerlink mtu 9216
- add bond comp0-bm-bond bond slaves swp11
- add bond comp0-bm-bond clag id 11
- add bond comp0-bm-bond bond mode 802.3ad
- add bond comp0-bm-bond bridge vids 15-18
- add bond comp0-bm-bond mtu 9000
vars_prompt:
- name: vars_prompt_username
prompt: "Enter your Cumulus username ?"
private: no
tasks:
- name: iterate nclu commands
community.network.nclu:
commands:
- "{{item}}"
with_item: {{file}}
when: item | length > 1
The expected outcome is that the commands can be iterated over and added to the device.
Some where along the road, this module with loops has been broken.
ACTUAL RESULTS
failed: [cumulus_test] (item=add bond peerlink bond slaves swp16) => {"ansible_loop_var": "item", "changed": false, "item": "add bond peerlink bond slaves swp16", "msg": "Error in pending config. You may want to view `net pending` on this target."}
failed: [cumulus_test] (item=add bond peerlink bond mode 802.3ad) => {"ansible_loop_var": "item", "changed": false, "item": "add bond peerlink bond mode 802.3ad", "msg": "Error in pending config. You may want to view `net pending` on this target."}
failed: [cumulus_test] (item=add bond peerlink mtu 9216) => {"ansible_loop_var": "item", "changed": false, "item": "add bond peerlink mtu 9216", "msg": "Error in pending config. You may want to view `net pending` on this target."}
failed: [cumulus_test] (item=add bond peerlink bond slaves swp32) => {"ansible_loop_var": "item", "changed": false, "item": "add bond peerlink bond slaves swp32", "msg": "Error in pending config. You may want to view `net pending` on this target."}
failed: [cumulus_test] (item=add bond peerlink bond mode 802.3ad) => {"ansible_loop_var": "item", "changed": false, "item": "add bond peerlink bond mode 802.3ad", "msg": "Error in pending config. You may want to view `net pending` on this target."}
failed: [cumulus_test] (item=add bond peerlink mtu 9216) => {"ansible_loop_var": "item", "changed": false, "item": "add bond peerlink mtu 9216", "msg": "Error in pending config. You may want to view `net pending` on this target."}
failed: [cumulus_test] (item=add bond comp0-bm-bond bond slaves swp11) => {"ansible_loop_var": "item", "changed": false, "item": "add bond comp0-bm-bond bond slaves swp11", "msg": "Error in pending config. You may want to view `net pending` on this target."}
failed: [cumulus_test] (item=add bond comp0-bm-bond clag id 11) => {"ansible_loop_var": "item", "changed": false, "item": "add bond comp0-bm-bond clag id 11", "msg": "Error in pending config. You may want to view `net pending` on this target."}
failed: [cumulus_test] (item=add bond comp0-bm-bond bond mode 802.3ad) => {"ansible_loop_var": "item", "changed": false, "item": "add bond comp0-bm-bond bond mode 802.3ad", "msg": "Error in pending config. You may want to view `net pending` on this target."}
failed: [cumulus_test] (item=add bond comp0-bm-bond bridge vids 15-18) => {"ansible_loop_var": "item", "changed": false, "item": "add bond comp0-bm-bond bridge vids 15-18", "msg": "Error in pending config. You may want to view `net pending` on this target."}
I used this extensively in the past and verified this worked as expected, but somewhere along the line this has been broken.
SUMMARY
community.network.nclu.commands module fails to function when the commands being passed to the module is using a loop mechanism. I have confirmed using with_items and also lines from a file with_lines.
Working Example:
Broken Example:
ISSUE TYPE
COMPONENT NAME
Cumulus Linux NCLU Commands Module
ANSIBLE VERSION
COLLECTION VERSION
-->
CONFIGURATION
OS / ENVIRONMENT
Cumulus Linux 4.0
STEPS TO REPRODUCE
Steps to reproduce can be performed using any looping with nclu commands module.
Broken PlayBook:
EXPECTED RESULTS
The module used to work when the module was used from this repo: https://github.com/IPvSean/ansible_nclu/blob/master/push_nclu.yml
The expected outcome is that the commands can be iterated over and added to the device. Some where along the road, this module with loops has been broken.
ACTUAL RESULTS