diff --git a/test/integration/ios.yaml b/test/integration/ios.yaml index 09ff697138..7e0bc264bd 100644 --- a/test/integration/ios.yaml +++ b/test/integration/ios.yaml @@ -1,6 +1,7 @@ --- - hosts: ios gather_facts: no + connection: local vars: limit_to: "*" @@ -11,3 +12,4 @@ - { role: ios_config, when: "limit_to in ['*', 'ios_config']" } - { role: ios_facts, when: "limit_to in ['*', 'ios_facts']" } - { role: ios_template, when: "limit_to in ['*', 'ios_template']" } + - { role: ios_system, when: "limit_to in ['*', 'ios_system']" } diff --git a/test/integration/iosxr.yaml b/test/integration/iosxr.yaml index 117d3aec30..e2d0960a2e 100644 --- a/test/integration/iosxr.yaml +++ b/test/integration/iosxr.yaml @@ -12,3 +12,4 @@ - { role: iosxr_config, when: "limit_to in ['*', 'iosxr_config']" } - { role: iosxr_facts, when: "limit_to in ['*', 'iosxr_facts']" } - { role: iosxr_template, when: "limit_to in ['*', 'iosxr_template']" } + - { role: iosxr_system, when: "limit_to in ['*', 'iosxr_system']" } diff --git a/test/integration/nxos.yaml b/test/integration/nxos.yaml index d5fca2b70f..a221e4e9a8 100644 --- a/test/integration/nxos.yaml +++ b/test/integration/nxos.yaml @@ -15,4 +15,5 @@ - { role: nxos_nxapi, when: "limit_to in ['*', 'nxos_nxapi']" } - { role: nxos_evpn_global, when: "limit_to in ['*', 'nxos_evpn_global']" } - { role: nxos_feature, when: "limit_to in ['*', 'nxos_feature']" } - - { role: nxos_feature, when: "limit_to in ['*', 'nxos_mtu']" } + - { role: nxos_mtu, when: "limit_to in ['*', 'nxos_mtu']" } + - { role: nxos_system, when: "limit_to in ['*', 'nxos_system']" } \ No newline at end of file diff --git a/test/integration/targets/eos_system/tasks/cli.yaml b/test/integration/targets/eos_system/tasks/cli.yaml index d675462dd0..ec835e9eb6 100644 --- a/test/integration/targets/eos_system/tasks/cli.yaml +++ b/test/integration/targets/eos_system/tasks/cli.yaml @@ -6,7 +6,7 @@ register: test_cases - name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" #" - name: run test case include: "{{ test_case_to_run }}" diff --git a/test/integration/targets/eos_system/tasks/eapi.yaml b/test/integration/targets/eos_system/tasks/eapi.yaml index 26c247320b..f39b09baef 100644 --- a/test/integration/targets/eos_system/tasks/eapi.yaml +++ b/test/integration/targets/eos_system/tasks/eapi.yaml @@ -6,13 +6,14 @@ register: test_cases - name: set test_items - set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" + set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}" #" - name: enable eapi - nxos_config: - lines: - - feature eapi - - eapi http port 80 + eos_eapi: + enable_http: yes + enable_https: yes + enable_local_http: yes + enable_socket: yes provider: "{{ cli }}" - name: run test case @@ -22,7 +23,9 @@ loop_var: test_case_to_run - name: disable eapi - nxos_config: - lines: - - no feature eapi + eos_eapi: + enable_http: no + enable_https: no + enable_local_http: no + enable_socket: no provider: "{{ cli }}" diff --git a/test/integration/targets/ios_system/meta/main.yml b/test/integration/targets/ios_system/meta/main.yml new file mode 100644 index 0000000000..159cea8d38 --- /dev/null +++ b/test/integration/targets/ios_system/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_ios_tests diff --git a/test/integration/targets/ios_system/tasks/cli.yaml b/test/integration/targets/ios_system/tasks/cli.yaml new file mode 100644 index 0000000000..46d86dd698 --- /dev/null +++ b/test/integration/targets/ios_system/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- 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/ios_system/tasks/main.yaml b/test/integration/targets/ios_system/tasks/main.yaml new file mode 100644 index 0000000000..415c99d8b1 --- /dev/null +++ b/test/integration/targets/ios_system/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/ios_system/tests/cli/set_domain_list.yaml b/test/integration/targets/ios_system/tests/cli/set_domain_list.yaml new file mode 100644 index 0000000000..bd62a39928 --- /dev/null +++ b/test/integration/targets/ios_system/tests/cli/set_domain_list.yaml @@ -0,0 +1,132 @@ +--- +- debug: msg="START cli/set_domain_search.yaml" + +- name: setup + ios_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + authorize: yes + provider: "{{ cli }}" + +- name: configure domain_search + ios_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == true + - "'ip domain list ansible.com' in result.commands" + - "'ip domain list redhat.com' in result.commands" + +- name: verify domain_search + ios_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == false + +- name: remove one entry + ios_system: + domain_search: + - ansible.com + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == true + - "'no ip domain list redhat.com' in result.commands" + +- name: verify remove one entry + ios_system: + domain_search: + - ansible.com + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == false + +- name: add one entry + ios_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == true + - "'ip domain list redhat.com' in result.commands" + +- name: verify add one entry + ios_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == false + +- name: add and remove one entry + ios_system: + domain_search: + - ansible.com + - eng.ansible.com + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == true + - "'no ip domain list redhat.com' in result.commands" + - "'ip domain list eng.ansible.com' in result.commands" + - result.commands|length == 2 + +- name: verify add and remove one entry + ios_system: + domain_search: + - ansible.com + - eng.ansible.com + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == false + +- name: teardown + ios_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + - no ip domain-list eng.ansible.com + match: none + authorize: yes + provider: "{{ cli }}" + +- debug: msg="END cli/set_domain_search.yaml" diff --git a/test/integration/targets/ios_system/tests/cli/set_domain_name.yaml b/test/integration/targets/ios_system/tests/cli/set_domain_name.yaml new file mode 100644 index 0000000000..eab5af8595 --- /dev/null +++ b/test/integration/targets/ios_system/tests/cli/set_domain_name.yaml @@ -0,0 +1,40 @@ +--- +- debug: msg="START cli/set_domain_name.yaml" + +- name: setup + ios_config: + lines: no ip domain-name + match: none + authorize: yes + provider: "{{ cli }}" + +- name: configure domain_name + ios_system: + domain_name: eng.ansible.com + authorize: yes + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: verify domain_name + ios_system: + domain_name: eng.ansible.com + authorize: yes + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + ios_config: + lines: no ip domain-name + match: none + authorize: yes + provider: "{{ cli }}" + +- debug: msg="END cli/set_domain_name.yaml" diff --git a/test/integration/targets/ios_system/tests/cli/set_hostname.yaml b/test/integration/targets/ios_system/tests/cli/set_hostname.yaml new file mode 100644 index 0000000000..d2e6dcc097 --- /dev/null +++ b/test/integration/targets/ios_system/tests/cli/set_hostname.yaml @@ -0,0 +1,40 @@ +--- +- debug: msg="START cli/set_hostname.yaml" + +- name: setup + ios_config: + lines: hostname switch + match: none + authorize: yes + provider: "{{ cli }}" + +- name: configure hostname + ios_system: + hostname: foo + authorize: yes + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: verify hostname + ios_system: + hostname: foo + authorize: yes + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + ios_config: + lines: "hostname {{ inventory_hostname }}" + match: none + authorize: yes + provider: "{{ cli }}" + +- debug: msg="END cli/set_hostname.yaml" diff --git a/test/integration/targets/ios_system/tests/cli/set_lookup_source.yaml b/test/integration/targets/ios_system/tests/cli/set_lookup_source.yaml new file mode 100644 index 0000000000..beed27a2e9 --- /dev/null +++ b/test/integration/targets/ios_system/tests/cli/set_lookup_source.yaml @@ -0,0 +1,76 @@ +--- +- debug: msg="START cli/set_lookup_source.yaml" + +- name: setup + ios_config: + lines: + - no ip domain lookup source-interface + - vrf definition ansible + match: none + authorize: yes + provider: "{{ cli }}" + +- name: configure lookup_source + ios_system: + lookup_source: Loopback10 + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == true + - "'ip domain lookup source-interface Loopback10' in result.commands" + +- name: verify lookup_source + ios_system: + lookup_source: Loopback10 + provider: "{{ cli }}" + authorize: yes + register: result + +- assert: + that: + - result.changed == false + +#- name: change to vrf +# ios_system: +# lookup_source: +# - interface: Loopback10 +# vrf: ansible +# authorize: yes +# provider: "{{ cli }}" +# register: result +# +#- assert: +# that: +# - result.changed == true +# - "'no ip domain lookup source-interface Management1' in result.commands" +# - "'ip domain lookup vrf ansible source-interface Management1' in result.commands" +# - result.commands|length == 2 +# +#- name: verify change to vrf +# ios_system: +# lookup_source: +# - interface: Management1 +# vrf: ansible +# authorize: yes +# provider: "{{ cli }}" +# register: result +# +#- assert: +# that: +# - result.changed == false + +- name: teardown + ios_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + authorize: yes + provider: "{{ cli }}" + ignore_errors: yes +# FIXME: Not sure why this is failing with msg": "no vrf definition ansible\r\n% IPv4 and IPv6 addresses from all interfaces in VRF ansible have been removed\r\nfoo(config)#", rc:1 + +- debug: msg="END cli/set_lookup_source.yaml" diff --git a/test/integration/targets/ios_system/tests/cli/set_name_servers.yaml b/test/integration/targets/ios_system/tests/cli/set_name_servers.yaml new file mode 100644 index 0000000000..1d515840e7 --- /dev/null +++ b/test/integration/targets/ios_system/tests/cli/set_name_servers.yaml @@ -0,0 +1,96 @@ +--- +- debug: msg="START cli/set_name_servers.yaml" + +- name: setup + ios_config: + lines: + - no ip name-server + match: none + authorize: yes + provider: "{{ cli }}" + +- name: configure name_servers + ios_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + - 3.3.3.3 + authorize: yes + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'ip name-server 1.1.1.1' in result.commands" + - "'ip name-server 2.2.2.2' in result.commands" + - "'ip name-server 3.3.3.3' in result.commands" + +- name: verify name_servers + ios_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + - 3.3.3.3 + authorize: yes + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +#- name: change to vrf +# ios_system: +# name_servers: +# - 1.1.1.1 +# - { server: 2.2.2.2, vrf: ansible } +# - 3.3.3.3 +# provider: "{{ cli }}" +# register: result + +#- assert: +# that: +# - result.changed == true +# - result.commands|length == 2 +# - "'no ip name-server 2.2.2.2' in result.commands" +# - "'ip name-server 2.2.2.2 vrf ansible' in result.commands" + +#- name: verify change to vrf +# ios_system: +# name_servers: +# - 1.1.1.1 +# - { server: 2.2.2.2, vrf: ansible } +# - 3.3.3.3 +# provider: "{{ cli }}" +# register: result +# +#- assert: +# that: +# - result.changed == false + +- name: remove one + ios_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + authorize: yes + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - "'no ip name-server 3.3.3.3' in result.commands" + +- name: teardown + ios_config: + lines: + - no ip domain lookup source-interface + match: none + authorize: yes + provider: "{{ cli }}" + +- debug: msg="END cli/set_name_servers.yaml" diff --git a/test/integration/targets/iosxr_system/meta/main.yml b/test/integration/targets/iosxr_system/meta/main.yml new file mode 100644 index 0000000000..d4da833dd5 --- /dev/null +++ b/test/integration/targets/iosxr_system/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_iosxr_tests diff --git a/test/integration/targets/iosxr_system/tasks/cli.yaml b/test/integration/targets/iosxr_system/tasks/cli.yaml new file mode 100644 index 0000000000..46d86dd698 --- /dev/null +++ b/test/integration/targets/iosxr_system/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- 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/iosxr_system/tasks/main.yaml b/test/integration/targets/iosxr_system/tasks/main.yaml new file mode 100644 index 0000000000..415c99d8b1 --- /dev/null +++ b/test/integration/targets/iosxr_system/tasks/main.yaml @@ -0,0 +1,2 @@ +--- +- { include: cli.yaml, tags: ['cli'] } diff --git a/test/integration/targets/iosxr_system/tests/cli/set_domain_list.yaml b/test/integration/targets/iosxr_system/tests/cli/set_domain_list.yaml new file mode 100644 index 0000000000..6b3db147c5 --- /dev/null +++ b/test/integration/targets/iosxr_system/tests/cli/set_domain_list.yaml @@ -0,0 +1,122 @@ +--- +- debug: msg="START cli/set_domain_search.yaml" + +- name: setup + iosxr_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + provider: "{{ cli }}" + +- name: configure domain_search + iosxr_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'domain list ansible.com' in result.commands" + - "'domain list redhat.com' in result.commands" + +- name: verify domain_search + iosxr_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: remove one entry + iosxr_system: + domain_search: + - ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'no domain list redhat.com' in result.commands" + +- name: verify remove one entry + iosxr_system: + domain_search: + - ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: add one entry + iosxr_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'domain list redhat.com' in result.commands" + +- name: verify add one entry + iosxr_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: add and remove one entry + iosxr_system: + domain_search: + - ansible.com + - eng.ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'no domain list redhat.com' in result.commands" + - "'domain list eng.ansible.com' in result.commands" + - result.commands|length == 2 + +- name: verify add and remove one entry + iosxr_system: + domain_search: + - ansible.com + - eng.ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: teardown + iosxr_config: + lines: + - no domain list ansible.com + - no domain list redhat.com + - no domain list eng.ansible.com + match: none + provider: "{{ cli }}" + +- debug: msg="END cli/set_domain_search.yaml" diff --git a/test/integration/targets/iosxr_system/tests/cli/set_domain_name.yaml b/test/integration/targets/iosxr_system/tests/cli/set_domain_name.yaml new file mode 100644 index 0000000000..fc14aaaa00 --- /dev/null +++ b/test/integration/targets/iosxr_system/tests/cli/set_domain_name.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START cli/set_domain_name.yaml" + +- name: setup + iosxr_config: + lines: no domain name + match: none + provider: "{{ cli }}" + +- name: configure domain_name + iosxr_system: + domain_name: eng.ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: verify domain_name + iosxr_system: + domain_name: eng.ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + iosxr_config: + lines: no domain name + match: none + provider: "{{ cli }}" + +- debug: msg="END cli/set_domain_name.yaml" diff --git a/test/integration/targets/iosxr_system/tests/cli/set_hostname.yaml b/test/integration/targets/iosxr_system/tests/cli/set_hostname.yaml new file mode 100644 index 0000000000..d9fd02212b --- /dev/null +++ b/test/integration/targets/iosxr_system/tests/cli/set_hostname.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START cli/set_hostname.yaml" + +- name: setup + iosxr_config: + lines: hostname switch + match: none + provider: "{{ cli }}" + +- name: configure hostname + iosxr_system: + hostname: foo + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: verify hostname + iosxr_system: + hostname: foo + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + iosxr_config: + lines: "hostname {{ inventory_hostname }}" + match: none + provider: "{{ cli }}" + +- debug: msg="END cli/set_hostname.yaml" diff --git a/test/integration/targets/iosxr_system/tests/cli/set_lookup_source.yaml b/test/integration/targets/iosxr_system/tests/cli/set_lookup_source.yaml new file mode 100644 index 0000000000..683145e2b3 --- /dev/null +++ b/test/integration/targets/iosxr_system/tests/cli/set_lookup_source.yaml @@ -0,0 +1,68 @@ +--- +- debug: msg="START cli/set_lookup_source.yaml" + +- name: setup + iosxr_config: + lines: + - no domain lookup source-interface Loopback10 +# - vrf ansible + match: none + provider: "{{ cli }}" + +- name: configure lookup_source + iosxr_system: + lookup_source: Loopback10 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'domain lookup source-interface Loopback10' in result.commands" + +- name: verify lookup_source + iosxr_system: + lookup_source: Loopback10 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +#- name: change to vrf +# iosxr_system: +# lookup_source: +# - interface: Loopback10 +# vrf: ansible +# provider: "{{ cli }}" +# register: result +# +#- assert: +# that: +# - result.changed == true +# - "'no ip domain lookup source-interface Management1' in result.commands" +# - "'ip domain lookup vrf ansible source-interface Management1' in result.commands" +# - result.commands|length == 2 +# +#- name: verify change to vrf +# iosxr_system: +# lookup_source: +# - interface: Management1 +# vrf: ansible +# provider: "{{ cli }}" +# register: result +# +#- assert: +# that: +# - result.changed == false + +- name: teardown + iosxr_config: + lines: + - no domain lookup source-interface Loopback10 + - no vrf ansible + match: none + provider: "{{ cli }}" + +- debug: msg="END cli/set_lookup_source.yaml" diff --git a/test/integration/targets/iosxr_system/tests/cli/set_name_servers.yaml b/test/integration/targets/iosxr_system/tests/cli/set_name_servers.yaml new file mode 100644 index 0000000000..58ad277f86 --- /dev/null +++ b/test/integration/targets/iosxr_system/tests/cli/set_name_servers.yaml @@ -0,0 +1,88 @@ +--- +- debug: msg="START cli/set_name_servers.yaml" + +- name: setup + iosxr_config: + lines: + - no ip name-server 1.1.1.1 + - no ip name-server 2.2.2.2 + - no ip name-server 3.3.3.3 + match: none + provider: "{{ cli }}" + +- name: configure name_servers + iosxr_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + - 3.3.3.3 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'domain name-server 1.1.1.1' in result.commands" + - "'domain name-server 2.2.2.2' in result.commands" + - "'domain name-server 3.3.3.3' in result.commands" + +- name: verify name_servers + iosxr_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + - 3.3.3.3 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +#- name: change to vrf +# iosxr_system: +# name_servers: +# - 1.1.1.1 +# - { server: 2.2.2.2, vrf: ansible } +# - 3.3.3.3 +# provider: "{{ cli }}" +# register: result + +#- assert: +# that: +# - result.changed == true +# - result.commands|length == 2 +# - "'no ip name-server 2.2.2.2' in result.commands" +# - "'ip name-server 2.2.2.2 vrf ansible' in result.commands" + +#- name: verify change to vrf +# iosxr_system: +# name_servers: +# - 1.1.1.1 +# - { server: 2.2.2.2, vrf: ansible } +# - 3.3.3.3 +# provider: "{{ cli }}" +# register: result +# +#- assert: +# that: +# - result.changed == false + +- name: remove one + iosxr_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - "'no domain name-server 3.3.3.3' in result.commands" + +# FIXME: No teardown +# +- debug: msg="END cli/set_name_servers.yaml" diff --git a/test/integration/targets/nxos_mtu/tests/cli/set_sysmtu.yaml b/test/integration/targets/nxos_mtu/tests/cli/set_sysmtu.yaml index 17b6802fbb..aa14aa62ea 100644 --- a/test/integration/targets/nxos_mtu/tests/cli/set_sysmtu.yaml +++ b/test/integration/targets/nxos_mtu/tests/cli/set_sysmtu.yaml @@ -11,6 +11,7 @@ nxos_mtu: sysmtu: 2000 provider: "{{ cli }}" + transport: nxapi register: result - assert: diff --git a/test/integration/targets/nxos_system/meta/main.yml b/test/integration/targets/nxos_system/meta/main.yml new file mode 100644 index 0000000000..ae741cbdc7 --- /dev/null +++ b/test/integration/targets/nxos_system/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - prepare_nxos_tests diff --git a/test/integration/targets/nxos_system/tasks/cli.yaml b/test/integration/targets/nxos_system/tasks/cli.yaml new file mode 100644 index 0000000000..46d86dd698 --- /dev/null +++ b/test/integration/targets/nxos_system/tasks/cli.yaml @@ -0,0 +1,16 @@ +--- +- name: collect all cli test cases + find: + paths: "{{ role_path }}/tests/cli" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- 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_system/tasks/main.yaml b/test/integration/targets/nxos_system/tasks/main.yaml new file mode 100644 index 0000000000..4b0f8c64d9 --- /dev/null +++ b/test/integration/targets/nxos_system/tasks/main.yaml @@ -0,0 +1,3 @@ +--- +- { include: cli.yaml, tags: ['cli'] } +- { include: nxapi.yaml, tags: ['nxapi'] } diff --git a/test/integration/targets/nxos_system/tasks/nxapi.yaml b/test/integration/targets/nxos_system/tasks/nxapi.yaml new file mode 100644 index 0000000000..fc67dff230 --- /dev/null +++ b/test/integration/targets/nxos_system/tasks/nxapi.yaml @@ -0,0 +1,29 @@ +--- +- name: collect all nxapi test cases + find: + paths: "{{ role_path }}/tests/nxapi" + patterns: "{{ testcase }}.yaml" + register: test_cases + delegate_to: localhost + +- 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_system/tests/cli/set_domain_list.yaml b/test/integration/targets/nxos_system/tests/cli/set_domain_list.yaml new file mode 100644 index 0000000000..244d674681 --- /dev/null +++ b/test/integration/targets/nxos_system/tests/cli/set_domain_list.yaml @@ -0,0 +1,122 @@ +--- +- debug: msg="START cli/set_domain_list.yaml" + +- name: setup + nxos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + match: none + provider: "{{ cli }}" + +- name: configure domain_list + nxos_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: verify domain_list + nxos_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: remove one entry + nxos_system: + domain_search: + - ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + +- name: verify remove one entry + nxos_system: + domain_search: + - ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: add one entry + nxos_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'ip domain-list redhat.com' in result.commands" + +- name: verify add one entry + nxos_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: add and remove one entry + nxos_system: + domain_search: + - ansible.com + - eng.ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + - "'ip domain-list eng.ansible.com' in result.commands" + - result.commands|length == 2 + +- name: verify add and remove one entry + nxos_system: + domain_search: + - ansible.com + - eng.ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: teardown + nxos_config: + lines: + - no ip domain-list ansible.com + - no ip domain-list redhat.com + - no ip domain-list eng.ansible.com + match: none + provider: "{{ cli }}" + +- debug: msg="END cli/set_domain_search.yaml" diff --git a/test/integration/targets/nxos_system/tests/cli/set_domain_name.yaml b/test/integration/targets/nxos_system/tests/cli/set_domain_name.yaml new file mode 100644 index 0000000000..9e0e08d9a3 --- /dev/null +++ b/test/integration/targets/nxos_system/tests/cli/set_domain_name.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START cli/set_domain_name.yaml" + +- name: setup + nxos_config: + lines: no ip domain-name eng.ansible.com + match: none + provider: "{{ cli }}" + +- name: configure domain_name + nxos_system: + domain_name: eng.ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: verify domain_name + nxos_system: + domain_name: eng.ansible.com + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + nxos_config: + lines: no ip domain-name eng.ansible.com + match: none + provider: "{{ cli }}" + +- debug: msg="END cli/set_domain_name.yaml" diff --git a/test/integration/targets/nxos_system/tests/cli/set_hostname.yaml b/test/integration/targets/nxos_system/tests/cli/set_hostname.yaml new file mode 100644 index 0000000000..8d82137d7c --- /dev/null +++ b/test/integration/targets/nxos_system/tests/cli/set_hostname.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START cli/set_hostname.yaml" + +- name: setup + nxos_config: + lines: hostname switch + match: none + provider: "{{ cli }}" + +- name: configure hostname + nxos_system: + hostname: foo + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: verify hostname + nxos_system: + hostname: foo + provider: "{{ cli }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + nxos_config: + lines: "hostname {{ inventory_hostname }}" + match: none + provider: "{{ cli }}" + +- debug: msg="END cli/set_hostname.yaml" diff --git a/test/integration/targets/nxos_system/tests/cli/set_lookup_source.yaml-not-on-nxos b/test/integration/targets/nxos_system/tests/cli/set_lookup_source.yaml-not-on-nxos new file mode 100644 index 0000000000..4a39a49882 --- /dev/null +++ b/test/integration/targets/nxos_system/tests/cli/set_lookup_source.yaml-not-on-nxos @@ -0,0 +1,68 @@ +--- +- debug: msg="START cli/set_lookup_source.yaml" + +- name: setup + nxos_config: + lines: + - no ip domain lookup source-interface + - vrf definition ansible + match: none + provider: "{{ cli }}" + +- name: configure lookup_source + nxos_system: + lookup_source: Management1 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'ip domain lookup source-interface Management1' in result.commands" + +- name: verify lookup_source + nxos_system: + lookup_source: Management1 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: change to vrf + nxos_system: + lookup_source: + - interface: Management1 + vrf: ansible + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - "'no ip domain lookup source-interface Management1' in result.commands" + - "'ip domain lookup vrf ansible source-interface Management1' in result.commands" + - result.commands|length == 2 + +- name: verify change to vrf + nxos_system: + lookup_source: + - interface: Management1 + vrf: ansible + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +- name: teardown + nxos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + provider: "{{ cli }}" + +- debug: msg="END cli/set_lookup_source.yaml" diff --git a/test/integration/targets/nxos_system/tests/cli/set_name_servers.yaml b/test/integration/targets/nxos_system/tests/cli/set_name_servers.yaml new file mode 100644 index 0000000000..735bbd26f3 --- /dev/null +++ b/test/integration/targets/nxos_system/tests/cli/set_name_servers.yaml @@ -0,0 +1,95 @@ +--- +- debug: msg="START cli/set_name_servers.yaml" + +- name: setup + nxos_config: + lines: + - no ip name-server 1.1.1.1 + - no ip name-server 2.2.2.2 + - no ip name-server 3.3.3.3 + match: none + provider: "{{ cli }}" + +- name: configure name_servers + nxos_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + - 3.3.3.3 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'ip name-server 1.1.1.1' in result.commands" + - "'ip name-server 2.2.2.2' in result.commands" + - "'ip name-server 3.3.3.3' in result.commands" + +- name: verify name_servers + nxos_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + - 3.3.3.3 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == false + +#- name: change to vrf +# nxos_system: +# name_servers: +# - 1.1.1.1 +# - { server: 2.2.2.2, vrf: ansible } +# - 3.3.3.3 +# provider: "{{ cli }}" +# register: result + +#- assert: +# that: +# - result.changed == true +# - result.commands|length == 2 +# - "'no ip name-server 2.2.2.2' in result.commands" +# - "'ip name-server 2.2.2.2 vrf ansible' in result.commands" + +#- name: verify change to vrf +# nxos_system: +# name_servers: +# - 1.1.1.1 +# - { server: 2.2.2.2, vrf: ansible } +# - 3.3.3.3 +# provider: "{{ cli }}" +# register: result +# +#- assert: +# that: +# - result.changed == false + +- name: remove one + nxos_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + provider: "{{ cli }}" + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - "'no ip name-server 3.3.3.3' in result.commands" + +- name: teardown + nxos_config: + lines: + - no ip lookup source-interface + match: none + provider: "{{ cli }}" + ignore_errors: yes + # FIXME Copied from iosxr, not sure what we need here + +- debug: msg="END cli/set_name_servers.yaml" diff --git a/test/integration/targets/nxos_system/tests/nxapi/set_domain_list.yaml b/test/integration/targets/nxos_system/tests/nxapi/set_domain_list.yaml new file mode 100644 index 0000000000..f19622f8a4 --- /dev/null +++ b/test/integration/targets/nxos_system/tests/nxapi/set_domain_list.yaml @@ -0,0 +1,131 @@ +--- +- debug: msg="START nxapi/set_domain_list.yaml" + + +# nxapi will error if you try and remove a non-existent entry, +# Therefore we do this as a with_items loop with ignore_errors +- name: setup + nxos_config: + lines: + - no ip domain-list {{ item }} + match: none + provider: "{{ nxapi }}" + ignore_errors: yes + with_items: + - ansible.com + - redhat.com + +- name: configure domain_list + nxos_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == true + - "'ip domain-list ansible.com' in result.commands" + - "'ip domain-list redhat.com' in result.commands" + +- name: verify domain_list + nxos_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == false + +- name: remove one entry + nxos_system: + domain_search: + - ansible.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + +- name: verify remove one entry + nxos_system: + domain_search: + - ansible.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == false + +- name: add one entry + nxos_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == true + - "'ip domain-list redhat.com' in result.commands" + +- name: verify add one entry + nxos_system: + domain_search: + - ansible.com + - redhat.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == false + +- name: add and remove one entry + nxos_system: + domain_search: + - ansible.com + - eng.ansible.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == true + - "'no ip domain-list redhat.com' in result.commands" + - "'ip domain-list eng.ansible.com' in result.commands" + - result.commands|length == 2 + +- name: verify add and remove one entry + nxos_system: + domain_search: + - ansible.com + - eng.ansible.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == false + +- name: teardown + nxos_config: + lines: + - no ip domain-list {{ item }} + match: none + provider: "{{ nxapi }}" + ignore_errors: yes + with_items: + - ansible.com + - redhat.com + - eng.ansible.com + +- debug: msg="END nxapi/set_domain_search.yaml" diff --git a/test/integration/targets/nxos_system/tests/nxapi/set_domain_name.yaml b/test/integration/targets/nxos_system/tests/nxapi/set_domain_name.yaml new file mode 100644 index 0000000000..a0585b1e31 --- /dev/null +++ b/test/integration/targets/nxos_system/tests/nxapi/set_domain_name.yaml @@ -0,0 +1,38 @@ +--- +- debug: msg="START nxapi/set_domain_name.yaml" + +- name: setup + nxos_config: + lines: no ip domain-name eng.ansible.com + match: none + provider: "{{ nxapi }}" +# NXAPI errors if you try to remove something that doesn't exist + ignore_errors: yes + +- name: configure domain_name + nxos_system: + domain_name: eng.ansible.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: verify domain_name + nxos_system: + domain_name: eng.ansible.com + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + nxos_config: + lines: no ip domain-name eng.ansible.com + match: none + provider: "{{ nxapi }}" + +- debug: msg="END nxapi/set_domain_name.yaml" diff --git a/test/integration/targets/nxos_system/tests/nxapi/set_hostname.yaml b/test/integration/targets/nxos_system/tests/nxapi/set_hostname.yaml new file mode 100644 index 0000000000..74398c800a --- /dev/null +++ b/test/integration/targets/nxos_system/tests/nxapi/set_hostname.yaml @@ -0,0 +1,36 @@ +--- +- debug: msg="START nxapi/set_hostname.yaml" + +- name: setup + nxos_config: + lines: hostname switch + match: none + provider: "{{ nxapi }}" + +- name: configure hostname + nxos_system: + hostname: foo + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - "result.changed == true" + +- name: verify hostname + nxos_system: + hostname: foo + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - "result.changed == false" + +- name: teardown + nxos_config: + lines: "hostname {{ inventory_hostname }}" + match: none + provider: "{{ nxapi }}" + +- debug: msg="END nxapi/set_hostname.yaml" diff --git a/test/integration/targets/nxos_system/tests/nxapi/set_lookup_source.yaml-not-on-nxos b/test/integration/targets/nxos_system/tests/nxapi/set_lookup_source.yaml-not-on-nxos new file mode 100644 index 0000000000..7a39bb2492 --- /dev/null +++ b/test/integration/targets/nxos_system/tests/nxapi/set_lookup_source.yaml-not-on-nxos @@ -0,0 +1,68 @@ +--- +- debug: msg="START nxapi/set_lookup_source.yaml" + +- name: setup + nxos_config: + lines: + - no ip domain lookup source-interface + - vrf definition ansible + match: none + provider: "{{ nxapi }}" + +- name: configure lookup_source + nxos_system: + lookup_source: Management1 + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == true + - "'ip domain lookup source-interface Management1' in result.commands" + +- name: verify lookup_source + nxos_system: + lookup_source: Management1 + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == false + +- name: change to vrf + nxos_system: + lookup_source: + - interface: Management1 + vrf: ansible + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == true + - "'no ip domain lookup source-interface Management1' in result.commands" + - "'ip domain lookup vrf ansible source-interface Management1' in result.commands" + - result.commands|length == 2 + +- name: verify change to vrf + nxos_system: + lookup_source: + - interface: Management1 + vrf: ansible + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == false + +- name: teardown + nxos_config: + lines: + - no ip domain lookup source-interface + - no vrf definition ansible + match: none + provider: "{{ nxapi }}" + +- debug: msg="END nxapi/set_lookup_source.yaml" diff --git a/test/integration/targets/nxos_system/tests/nxapi/set_name_servers.yaml b/test/integration/targets/nxos_system/tests/nxapi/set_name_servers.yaml new file mode 100644 index 0000000000..39620572d2 --- /dev/null +++ b/test/integration/targets/nxos_system/tests/nxapi/set_name_servers.yaml @@ -0,0 +1,101 @@ +--- +- debug: msg="START nxapi/set_name_servers.yaml" + + +# nxapi will error if you try and remove a non-existent entry, +# Therefore we do this as a with_items loop with ignore_errors +- name: setup + nxos_config: + lines: + - no ip name-server {{ item }} + match: none + provider: "{{ nxapi }}" + ignore_errors: yes + with_items: + - 1.1.1.1 + - 2.2.2.2 + - 3.3.3.3 + +- name: configure name_servers + nxos_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + - 3.3.3.3 + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 3 + - "'ip name-server 1.1.1.1' in result.commands" + - "'ip name-server 2.2.2.2' in result.commands" + - "'ip name-server 3.3.3.3' in result.commands" + +- name: verify name_servers + nxos_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + - 3.3.3.3 + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == false + +#- name: change to vrf +# nxos_system: +# name_servers: +# - 1.1.1.1 +# - { server: 2.2.2.2, vrf: ansible } +# - 3.3.3.3 +# provider: "{{ nxapi }}" +# register: result + +#- assert: +# that: +# - result.changed == true +# - result.commands|length == 2 +# - "'no ip name-server 2.2.2.2' in result.commands" +# - "'ip name-server 2.2.2.2 vrf ansible' in result.commands" + +#- name: verify change to vrf +# nxos_system: +# name_servers: +# - 1.1.1.1 +# - { server: 2.2.2.2, vrf: ansible } +# - 3.3.3.3 +# provider: "{{ nxapi }}" +# register: result +# +#- assert: +# that: +# - result.changed == false + +- name: remove one + nxos_system: + name_servers: + - 1.1.1.1 + - 2.2.2.2 + provider: "{{ nxapi }}" + register: result + +- assert: + that: + - result.changed == true + - result.commands|length == 1 + - "'no ip name-server 3.3.3.3' in result.commands" + +- name: teardown + nxos_config: + lines: + - no ip lookup source-interface + match: none + provider: "{{ nxapi }}" + ignore_errors: yes + # FIXME Copied from iosxr, not sure what we need here + +- debug: msg="END nxapi/set_name_servers.yaml"