diff --git a/lib/ansible/module_utils/network/eos/config/vlans/vlans.py b/lib/ansible/module_utils/network/eos/config/vlans/vlans.py index bb1a0652063..b62c85d315b 100644 --- a/lib/ansible/module_utils/network/eos/config/vlans/vlans.py +++ b/lib/ansible/module_utils/network/eos/config/vlans/vlans.py @@ -197,6 +197,9 @@ class Vlans(ConfigBase): def generate_commands(vlan_id, to_set, to_remove): commands = [] for key, value in to_set.items(): + if value is None: + continue + commands.append("{0} {1}".format(key, value)) for key in to_remove.keys(): diff --git a/test/integration/targets/eos_vlans/tests/cli/idempotent.yaml b/test/integration/targets/eos_vlans/tests/cli/idempotent.yaml new file mode 100644 index 00000000000..d88e318ba9f --- /dev/null +++ b/test/integration/targets/eos_vlans/tests/cli/idempotent.yaml @@ -0,0 +1,21 @@ +--- +- eos_facts: + gather_network_resources: vlans + become: yes + +- name: Ensures that facts are idempotent through replace + eos_vlans: + config: "{{ ansible_facts.network_resources.vlans }}" + state: replaced + register: result + become: yes + +- eos_facts: + gather_network_resources: vlans + become: yes + +- assert: + that: + - "result.changed == False" + - "result.commands == []" + - "ansible_facts.network_resources.vlans|symmetric_difference(result.before) == []"