mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Test system (#22420)
* ios_system * tests for ios_system * tests for *_system * working ios_system on cli * Typo * Loopback10 (single word, upeprcase) * Revert docs changes * Working iosxr_system tests * eos, not nxos * nxos_system
This commit is contained in:
parent
0b250016b0
commit
41f5648c44
36 changed files with 1573 additions and 10 deletions
|
@ -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']" }
|
||||
|
|
|
@ -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']" }
|
||||
|
|
|
@ -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']" }
|
|
@ -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 }}"
|
||||
|
|
|
@ -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 }}"
|
||||
|
|
2
test/integration/targets/ios_system/meta/main.yml
Normal file
2
test/integration/targets/ios_system/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_ios_tests
|
16
test/integration/targets/ios_system/tasks/cli.yaml
Normal file
16
test/integration/targets/ios_system/tasks/cli.yaml
Normal file
|
@ -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
|
2
test/integration/targets/ios_system/tasks/main.yaml
Normal file
2
test/integration/targets/ios_system/tasks/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
2
test/integration/targets/iosxr_system/meta/main.yml
Normal file
2
test/integration/targets/iosxr_system/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_iosxr_tests
|
16
test/integration/targets/iosxr_system/tasks/cli.yaml
Normal file
16
test/integration/targets/iosxr_system/tasks/cli.yaml
Normal file
|
@ -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
|
2
test/integration/targets/iosxr_system/tasks/main.yaml
Normal file
2
test/integration/targets/iosxr_system/tasks/main.yaml
Normal file
|
@ -0,0 +1,2 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -11,6 +11,7 @@
|
|||
nxos_mtu:
|
||||
sysmtu: 2000
|
||||
provider: "{{ cli }}"
|
||||
transport: nxapi
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
|
|
2
test/integration/targets/nxos_system/meta/main.yml
Normal file
2
test/integration/targets/nxos_system/meta/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
|||
dependencies:
|
||||
- prepare_nxos_tests
|
16
test/integration/targets/nxos_system/tasks/cli.yaml
Normal file
16
test/integration/targets/nxos_system/tasks/cli.yaml
Normal file
|
@ -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
|
3
test/integration/targets/nxos_system/tasks/main.yaml
Normal file
3
test/integration/targets/nxos_system/tasks/main.yaml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
- { include: cli.yaml, tags: ['cli'] }
|
||||
- { include: nxapi.yaml, tags: ['nxapi'] }
|
29
test/integration/targets/nxos_system/tasks/nxapi.yaml
Normal file
29
test/integration/targets/nxos_system/tasks/nxapi.yaml
Normal file
|
@ -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 }}"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
|
@ -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"
|
Loading…
Reference in a new issue