diff --git a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py index 4a3b36a6062..a2278363c45 100644 --- a/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py +++ b/lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py @@ -150,7 +150,7 @@ def get_value(arg, config, module): value = '' if arg == 'description': if NO_DESC_REGEX.search(config): - value = '' + value = False elif PARAM_TO_COMMAND_KEYMAP[arg] in config: value = REGEX.search(config).group('value').strip() elif arg == 'source_interface': @@ -169,7 +169,7 @@ def get_value(arg, config, module): def get_existing(module, args): existing = {} - netcfg = CustomNetworkConfig(indent=2, contents=get_config(module)) + netcfg = CustomNetworkConfig(indent=2, contents=get_config(module, flags=['all'])) interface_string = 'interface {0}'.format(module.params['interface'].lower()) parents = [interface_string] @@ -294,18 +294,14 @@ def main(): proposed = {} for key, value in proposed_args.items(): if key != 'interface': - if str(value).lower() == 'true': - value = True - elif str(value).lower() == 'false': - value = False - elif str(value).lower() == 'default': + if str(value).lower() == 'default': value = PARAM_TO_DEFAULT_KEYMAP.get(key) if value is None: if key in BOOL_PARAMS: value = False else: value = 'default' - if existing.get(key) != value: + if str(existing.get(key)).lower() != str(value).lower(): proposed[key] = value candidate = CustomNetworkConfig(indent=3) diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml index 84b18a06d6c..129428b84fc 100644 --- a/test/integration/nxos.yaml +++ b/test/integration/nxos.yaml @@ -213,6 +213,15 @@ failed_modules: "{{ failed_modules }} + [ 'nxos_portchannel' ]" test_failed: true + - block: + - include_role: + name: nxos_vxlan_vtep + when: "limit_to in ['*', 'nxos_vxlan_vtep']" + rescue: + - set_fact: + failed_modules: "{{ failed_modules }} + [ 'nxos_vxlan_vtep' ]" + test_failed: true + - block: - include_role: name: nxos_logging diff --git a/test/integration/targets/nxos_vxlan_vtep/defaults/main.yaml b/test/integration/targets/nxos_vxlan_vtep/defaults/main.yaml new file mode 100644 index 00000000000..5f709c5aac1 --- /dev/null +++ b/test/integration/targets/nxos_vxlan_vtep/defaults/main.yaml @@ -0,0 +1,2 @@ +--- +testcase: "*" diff --git a/test/integration/targets/nxos_vxlan_vtep/meta/main.yml b/test/integration/targets/nxos_vxlan_vtep/meta/main.yml new file mode 100644 index 00000000000..ae741cbdc71 --- /dev/null +++ b/test/integration/targets/nxos_vxlan_vtep/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml b/test/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml new file mode 100644 index 00000000000..d675462dd02 --- /dev/null +++ b/test/integration/targets/nxos_vxlan_vtep/tasks/cli.yaml @@ -0,0 +1,15 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run diff --git a/test/integration/targets/nxos_vxlan_vtep/tasks/main.yaml b/test/integration/targets/nxos_vxlan_vtep/tasks/main.yaml new file mode 100644 index 00000000000..4b0f8c64d90 --- /dev/null +++ b/test/integration/targets/nxos_vxlan_vtep/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml b/test/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml new file mode 100644 index 00000000000..ea525379f7f --- /dev/null +++ b/test/integration/targets/nxos_vxlan_vtep/tasks/nxapi.yaml @@ -0,0 +1,28 @@ +--- +- name: collect all nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: test_cases + +- name: set test_items + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + +- name: enable nxapi + nxos_config: + lines: + - feature nxapi + - nxapi http port 80 + provider: "{{ cli }}" + +- name: run test case + include: "{{ test_case_to_run }}" + with_items: "{{ test_items }}" + loop_control: + loop_var: test_case_to_run + +- name: disable nxapi + nxos_config: + lines: + - no feature nxapi + provider: "{{ cli }}" diff --git a/test/integration/targets/nxos_vxlan_vtep/tests/cli/sanity.yaml b/test/integration/targets/nxos_vxlan_vtep/tests/cli/sanity.yaml new file mode 100644 index 00000000000..e15740a6082 --- /dev/null +++ b/test/integration/targets/nxos_vxlan_vtep/tests/cli/sanity.yaml @@ -0,0 +1,4 @@ +--- +- set_fact: connection="{{ cli }}" + +- import_tasks: targets/nxos_vxlan_vtep/tests/common/sanity.yaml diff --git a/test/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml b/test/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml new file mode 100644 index 00000000000..fcec0d5a625 --- /dev/null +++ b/test/integration/targets/nxos_vxlan_vtep/tests/common/sanity.yaml @@ -0,0 +1,65 @@ +--- +- - debug: msg="START TRANSPORT:{{ connection.transport }} nxos_vxlan_vtep sanity test" + +- block: + - name: "Enable feature nv overlay" + nxos_config: + commands: + - feature nv overlay + provider: "{{ connection }}" + match: none + + - name: configure vxlan_vtep + nxos_vxlan_vtep: &configure + interface: nve1 + description: default + host_reachability: true + source_interface: Loopback0 + source_interface_hold_down_time: 30 + shutdown: true + provider: "{{ connection }}" + register: result + + - assert: &true + that: + - "result.changed == true" + + - name: "Conf Idempotence" + nxos_vxlan_vtep: *configure + register: result + + - assert: &false + that: + - "result.changed == false" + + - name: remove vxlan_vtep + nxos_vxlan_vtep: &remove + interface: nve1 + description: default + host_reachability: true + source_interface: Loopback0 + source_interface_hold_down_time: 30 + shutdown: true + state: absent + provider: "{{ connection }}" + register: result + + - assert: *true + + - name: "Remove Idempotence" + nxos_vxlan_vtep: *remove + register: result + + - assert: *false + + when: (platform | search('N9K')) + + always: + - name: "Disable feature nv overlay" + nxos_feature: + feature: nve + state: disabled + provider: "{{ connection }}" + ignore_errors: yes + +- debug: msg="END TRANSPORT:{{ connection.transport }} nxos_vxlan_vtep sanity test" diff --git a/test/integration/targets/nxos_vxlan_vtep/tests/nxapi/sanity.yaml b/test/integration/targets/nxos_vxlan_vtep/tests/nxapi/sanity.yaml new file mode 100644 index 00000000000..ad578b6f320 --- /dev/null +++ b/test/integration/targets/nxos_vxlan_vtep/tests/nxapi/sanity.yaml @@ -0,0 +1,4 @@ +--- +- set_fact: connection="{{ nxapi }}" + +- import_tasks: targets/nxos_vxlan_vtep/tests/common/sanity.yaml