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:
John R Barker 2017-03-08 19:21:45 +00:00 committed by Chris Alfonso
commit 41f5648c44
36 changed files with 1573 additions and 10 deletions

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"

View file

@ -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"