From 841d204d0d90ed6dc03715ae8affcb045c5cb190 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Wed, 28 Aug 2019 13:53:33 -0400 Subject: [PATCH] Fixes #61244 (#61432) --- .../network/eos/config/vlans/vlans.py | 3 +++ .../eos_vlans/tests/cli/idempotent.yaml | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 test/integration/targets/eos_vlans/tests/cli/idempotent.yaml 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) == []"