1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

ios test changes (#35510)

* Fix over-byte

* Update ios tests to call `provider`

To continue to support testing `connection: local`

* Fix command dict handling in ios_user

* Clean up unit tests, too
This commit is contained in:
Nathaniel Case 2018-02-02 09:50:15 -05:00 committed by GitHub
parent d7d9e40dd1
commit f3337e1fba
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
49 changed files with 240 additions and 243 deletions

View file

@ -181,12 +181,12 @@ def validate_privilege(value, module):
def user_del_cmd(username): def user_del_cmd(username):
return json.dumps({ return {
'command': 'no username %s' % username, 'command': 'no username %s' % username,
'prompt': 'This operation will remove all username related configurations with same name', 'prompt': 'This operation will remove all username related configurations with same name',
'answer': 'y', 'answer': 'y',
'newline': False, 'newline': False,
}) }
def map_obj_to_commands(updates, module): def map_obj_to_commands(updates, module):

View file

@ -19,7 +19,6 @@
from __future__ import (absolute_import, division, print_function) from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import ast
import re import re
import json import json
@ -58,9 +57,9 @@ class Cliconf(CliconfBase):
if source not in ('running', 'startup'): if source not in ('running', 'startup'):
return self.invalid_params("fetching configuration from %s is not supported" % source) return self.invalid_params("fetching configuration from %s is not supported" % source)
if source == 'running': if source == 'running':
cmd = b'show running-config all' cmd = 'show running-config all'
else: else:
cmd = b'show startup-config' cmd = 'show startup-config'
flags = [] if flags is None else flags flags = [] if flags is None else flags
cmd += ' '.join(flags) cmd += ' '.join(flags)
@ -71,13 +70,12 @@ class Cliconf(CliconfBase):
@enable_mode @enable_mode
def edit_config(self, command): def edit_config(self, command):
for cmd in chain(['configure terminal'], to_list(command), ['end']): for cmd in chain(['configure terminal'], to_list(command), ['end']):
try: if isinstance(cmd, dict):
cmd = ast.literal_eval(cmd)
command = cmd['command'] command = cmd['command']
prompt = cmd['prompt'] prompt = cmd['prompt']
answer = cmd['answer'] answer = cmd['answer']
newline = cmd.get('newline', True) newline = cmd.get('newline', True)
except: else:
command = cmd command = cmd
prompt = None prompt = None
answer = None answer = None

View file

@ -4,7 +4,7 @@
ios_banner: ios_banner:
banner: login banner: login
state: absent state: absent
authorize: yes provider: "{{ cli }}"
- name: Set login - name: Set login
@ -15,7 +15,7 @@
that has a multiline that has a multiline
string string
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
@ -35,7 +35,7 @@
that has a multiline that has a multiline
string string
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result

View file

@ -4,7 +4,7 @@
ios_banner: ios_banner:
banner: motd banner: motd
state: absent state: absent
authorize: yes provider: "{{ cli }}"
- name: Set motd - name: Set motd
@ -15,7 +15,7 @@
that has a multiline that has a multiline
string string
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
@ -35,7 +35,7 @@
that has a multiline that has a multiline
string string
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result

View file

@ -6,13 +6,13 @@
Junk login banner Junk login banner
over multiple lines over multiple lines
state: present state: present
authorize: yes provider: "{{ cli }}"
- name: remove login - name: remove login
ios_banner: ios_banner:
banner: login banner: login
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- debug: - debug:
@ -27,7 +27,7 @@
ios_banner: ios_banner:
banner: login banner: login
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -6,7 +6,7 @@
commands: commands:
- show version - show version
- show interfaces GigabitEthernet 0/0 - show interfaces GigabitEthernet 0/0
authorize: yes provider: "{{ cli }}"
wait_for: wait_for:
- "result[0] contains 'Description: Foo'" - "result[0] contains 'Description: Foo'"
register: result register: result

View file

@ -6,7 +6,7 @@
commands: commands:
- show version - show version
- show interface loopback 888 - show interface loopback 888
authorize: yes provider: "{{ cli }}"
wait_for: wait_for:
- "result[0] contains Cisco" - "result[0] contains Cisco"
- "result[1] contains Loopback888" - "result[1] contains Loopback888"

View file

@ -4,7 +4,7 @@
- name: run invalid command - name: run invalid command
ios_command: ios_command:
commands: show foo commands: show foo
authorize: yes provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes
@ -17,7 +17,7 @@
commands: commands:
- show version - show version
- show foo - show foo
authorize: yes provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

@ -5,7 +5,7 @@
ios_command: ios_command:
commands: commands:
- show version - show version
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -18,7 +18,7 @@
commands: commands:
- show version - show version
- show interfaces - show interfaces
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -5,7 +5,7 @@
ios_command: ios_command:
commands: commands:
- show version - show version
authorize: yes provider: "{{ cli }}"
wait_for: wait_for:
- "result[0] contains bad_value_string" - "result[0] contains bad_value_string"
register: result register: result

View file

@ -9,7 +9,7 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: collect any backup files - name: collect any backup files
find: find:
@ -28,7 +28,7 @@
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
backup: yes backup: yes
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -9,13 +9,13 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure device with defaults included - name: configure device with defaults included
ios_config: ios_config:
src: defaults/config.j2 src: defaults/config.j2
defaults: yes defaults: yes
authorize: yes provider: "{{ cli }}"
register: result register: result
- debug: var=result - debug: var=result
@ -30,7 +30,7 @@
ios_config: ios_config:
src: defaults/config.j2 src: defaults/config.j2
defaults: yes defaults: yes
authorize: yes provider: "{{ cli }}"
register: result register: result
- debug: var=result - debug: var=result
@ -44,14 +44,14 @@
ios_config: ios_config:
lines: lines:
- mac-address-table notification mac-move - mac-address-table notification mac-move
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: show interfaces brief to ensure deivce goes to valid prompt - name: show interfaces brief to ensure deivce goes to valid prompt
ios_command: ios_command:
commands: commands:
- show interfaces - show interfaces
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -9,13 +9,13 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: save config - name: save config
ios_config: ios_config:
save: true save: true
authorize: yes provider: "{{ cli }}"
register: result register: result
# FIXME https://github.com/ansible/ansible-modules-core/issues/5008 # FIXME https://github.com/ansible/ansible-modules-core/issues/5008
ignore_errors: true ignore_errors: true
@ -29,7 +29,7 @@
- name: save should always run - name: save should always run
ios_config: ios_config:
save: true save: true
authorize: yes provider: "{{ cli }}"
register: result register: result
# FIXME https://github.com/ansible/ansible-modules-core/issues/5008 # FIXME https://github.com/ansible/ansible-modules-core/issues/5008
ignore_errors: true ignore_errors: true
@ -40,7 +40,7 @@
lines: lines:
- "no ip http server" - "no ip http server"
save_when: modified save_when: modified
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: save should always run - name: save should always run
@ -49,7 +49,7 @@
lines: lines:
- "ip http server" - "ip http server"
save_when: modified save_when: modified
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -60,7 +60,7 @@
ios_config: ios_config:
lines: lines:
- "no ip http server" - "no ip http server"
authorize: yes provider: "{{ cli }}"
register: result register: result
- debug: msg="END cli/save.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/save.yaml on connection={{ ansible_connection }}"

View file

@ -9,12 +9,12 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure device with config - name: configure device with config
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: debug, remove me - name: debug, remove me
@ -30,7 +30,7 @@
- name: check device with config - name: check device with config
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -6,7 +6,7 @@
- name: configure with invalid src - name: configure with invalid src
ios_config: ios_config:
src: basic/foobar.j2 src: basic/foobar.j2
authorize: yes provider: "{{ cli }}"
register: result register: result
ignore_errors: yes ignore_errors: yes

View file

@ -9,13 +9,13 @@
parents: parents:
- interface Loopback999 - interface Loopback999
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure device with config - name: configure device with config
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
match: none match: none
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -28,7 +28,7 @@
- name: check device with config - name: check device with config
ios_config: ios_config:
src: basic/config.j2 src: basic/config.j2
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -7,13 +7,13 @@
- 'no ip access-list extended test' - 'no ip access-list extended test'
- 'no ip access-list standard test' - 'no ip access-list standard test'
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure sub level command - name: configure sub level command
ios_config: ios_config:
lines: ['permit ip any any log'] lines: ['permit ip any any log']
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -26,7 +26,7 @@
ios_config: ios_config:
lines: ['permit ip any any log'] lines: ['permit ip any any log']
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -38,6 +38,6 @@
lines: lines:
- 'no ip access-list extended test' - 'no ip access-list extended test'
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/sublevel.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/sublevel.yaml on connection={{ ansible_connection }}"

View file

@ -10,7 +10,7 @@
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
before: ['no ip access-list extended test'] before: ['no ip access-list extended test']
after: ['exit'] after: ['exit']
authorize: yes provider: "{{ cli }}"
match: none match: none
- name: configure sub level command using block resplace - name: configure sub level command using block resplace
@ -23,7 +23,7 @@
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
replace: block replace: block
after: ['exit'] after: ['exit']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -45,7 +45,7 @@
parents: ['ip access-list extended test'] parents: ['ip access-list extended test']
replace: block replace: block
after: ['exit'] after: ['exit']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -57,6 +57,6 @@
lines: lines:
- no ip access-list extended test - no ip access-list extended test
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/sublevel_block.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/sublevel_block.yaml on connection={{ ansible_connection }}"

View file

@ -13,7 +13,7 @@
before: no ip access-list extended test before: no ip access-list extended test
after: exit after: exit
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure sub level command using exact match - name: configure sub level command using exact match
ios_config: ios_config:
@ -26,7 +26,7 @@
before: no ip access-list extended test before: no ip access-list extended test
after: exit after: exit
match: exact match: exact
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -48,7 +48,7 @@
- permit ip host 4.4.4.4 any log - permit ip host 4.4.4.4 any log
parents: ip access-list extended test parents: ip access-list extended test
match: exact match: exact
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -60,6 +60,6 @@
lines: lines:
- no ip access-list extended test - no ip access-list extended test
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/sublevel_exact.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/sublevel_exact.yaml on connection={{ ansible_connection }}"

View file

@ -12,7 +12,7 @@
parents: ip access-list extended test parents: ip access-list extended test
before: no ip access-list extended test before: no ip access-list extended test
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure sub level command using strict match - name: configure sub level command using strict match
ios_config: ios_config:
@ -23,7 +23,7 @@
- permit ip host 4.4.4.4 any log - permit ip host 4.4.4.4 any log
parents: ip access-list extended test parents: ip access-list extended test
match: strict match: strict
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -39,7 +39,7 @@
parents: ip access-list extended test parents: ip access-list extended test
after: exit after: exit
match: strict match: strict
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -56,6 +56,6 @@
ios_config: ios_config:
lines: no ip access-list extended test lines: no ip access-list extended test
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/sublevel_strict.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/sublevel_strict.yaml on connection={{ ansible_connection }}"

View file

@ -5,12 +5,12 @@
ios_config: ios_config:
lines: ['hostname {{ shorter_hostname }}'] lines: ['hostname {{ shorter_hostname }}']
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure top level command - name: configure top level command
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -21,7 +21,7 @@
- name: configure top level command idempotent check - name: configure top level command idempotent check
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -32,6 +32,6 @@
ios_config: ios_config:
lines: ['hostname {{ shorter_hostname }}'] lines: ['hostname {{ shorter_hostname }}']
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/toplevel.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/toplevel.yaml on connection={{ ansible_connection }}"

View file

@ -7,13 +7,13 @@
- "snmp-server contact ansible" - "snmp-server contact ansible"
- "hostname {{ shorter_hostname }}" - "hostname {{ shorter_hostname }}"
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure top level command with before - name: configure top level command with before
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
after: ['snmp-server contact bar'] after: ['snmp-server contact bar']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -26,7 +26,7 @@
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
after: ['snmp-server contact foo'] after: ['snmp-server contact foo']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -39,6 +39,6 @@
- "no snmp-server contact" - "no snmp-server contact"
- "hostname {{ shorter_hostname }}" - "hostname {{ shorter_hostname }}"
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/toplevel_after.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/toplevel_after.yaml on connection={{ ansible_connection }}"

View file

@ -7,13 +7,13 @@
- "snmp-server contact ansible" - "snmp-server contact ansible"
- "hostname {{ shorter_hostname }}" - "hostname {{ shorter_hostname }}"
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure top level command with before - name: configure top level command with before
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
before: ['snmp-server contact bar'] before: ['snmp-server contact bar']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -26,7 +26,7 @@
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
before: ['snmp-server contact foo'] before: ['snmp-server contact foo']
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -39,6 +39,6 @@
- "no snmp-server contact" - "no snmp-server contact"
- "hostname {{ shorter_hostname }}" - "hostname {{ shorter_hostname }}"
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/toplevel_before.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/toplevel_before.yaml on connection={{ ansible_connection }}"

View file

@ -5,13 +5,13 @@
ios_config: ios_config:
lines: ['hostname {{ shorter_hostname }}'] lines: ['hostname {{ shorter_hostname }}']
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure top level command - name: configure top level command
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
match: strict match: strict
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -23,7 +23,7 @@
ios_config: ios_config:
lines: ['hostname foo'] lines: ['hostname foo']
match: strict match: strict
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -34,6 +34,6 @@
ios_config: ios_config:
lines: ['hostname {{ shorter_hostname }}'] lines: ['hostname {{ shorter_hostname }}']
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/toplevel_nonidempotent.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/toplevel_nonidempotent.yaml on connection={{ ansible_connection }}"

View file

@ -6,7 +6,7 @@
ios_facts: ios_facts:
gather_subset: gather_subset:
- all - all
authorize: yes provider: "{{ cli }}"
register: result register: result

View file

@ -4,7 +4,7 @@
- name: test getting default facts - name: test getting default facts
ios_facts: ios_facts:
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -6,7 +6,7 @@
ios_facts: ios_facts:
gather_subset: gather_subset:
- "foobar" - "foobar"
authorize: yes provider: "{{ cli }}"
register: result register: result
ignore_errors: true ignore_errors: true
@ -29,7 +29,7 @@
gather_subset: gather_subset:
- "!hardware" - "!hardware"
- "hardware" - "hardware"
authorize: yes provider: "{{ cli }}"
register: result register: result
ignore_errors: true ignore_errors: true

View file

@ -6,7 +6,7 @@
ios_facts: ios_facts:
gather_subset: gather_subset:
- "!hardware" - "!hardware"
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -8,7 +8,7 @@
speed: 1000 speed: 1000
mtu: 1800 mtu: 1800
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: Configure interface - name: Configure interface
@ -16,7 +16,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
description: test-interface-initial description: test-interface-initial
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -30,7 +30,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
description: test-interface-initial description: test-interface-initial
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -43,7 +43,7 @@
description: test-interface description: test-interface
mtu: 2000 mtu: 2000
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -59,7 +59,7 @@
description: test-interface-1 description: test-interface-1
mtu: 1800 mtu: 1800
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -73,7 +73,7 @@
ios_interface: ios_interface:
name: "{{ test_interface }}" name: "{{ test_interface }}"
enabled: False enabled: False
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -86,7 +86,7 @@
ios_interface: ios_interface:
name: "{{ test_interface }}" name: "{{ test_interface }}"
enabled: True enabled: True
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -102,7 +102,7 @@
speed: 1000 speed: 1000
mtu: 1800 mtu: 1800
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: Add interface aggregate - name: Add interface aggregate
@ -112,7 +112,7 @@
- { name: "{{ test_interface2 }}", mtu: 2000, description: test-interface-2 } - { name: "{{ test_interface2 }}", mtu: 2000, description: test-interface-2 }
speed: 1000 speed: 1000
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -131,7 +131,7 @@
- { name: "{{ test_interface2 }}", mtu: 2000, description: test-interface-2 } - { name: "{{ test_interface2 }}", mtu: 2000, description: test-interface-2 }
speed: 1000 speed: 1000
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -145,7 +145,7 @@
- { name: "{{ test_interface2 }}" } - { name: "{{ test_interface2 }}" }
enabled: False enabled: False
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -163,7 +163,7 @@
- { name: "{{ test_interface2 }}" } - { name: "{{ test_interface2 }}" }
enabled: True enabled: True
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -180,7 +180,7 @@
- name: Loopback9 - name: Loopback9
- name: Loopback10 - name: Loopback10
state: absent state: absent
authorize: yes provider: "{{ cli }}"
- name: Create loopback interface aggregate - name: Create loopback interface aggregate
ios_interface: ios_interface:
@ -188,7 +188,7 @@
- name: Loopback9 - name: Loopback9
- name: Loopback10 - name: Loopback10
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -203,7 +203,7 @@
- name: Loopback9 - name: Loopback9
- name: Loopback10 - name: Loopback10
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -218,7 +218,7 @@
- name: Loopback9 - name: Loopback9
- name: Loopback10 - name: Loopback10
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -7,7 +7,7 @@
state: up state: up
tx_rate: ge(0) tx_rate: ge(0)
rx_rate: ge(0) rx_rate: ge(0)
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -20,7 +20,7 @@
state: down state: down
tx_rate: gt(0) tx_rate: gt(0)
rx_rate: lt(0) rx_rate: lt(0)
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
register: result register: result
@ -36,7 +36,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
enabled: False enabled: False
state: down state: down
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -47,7 +47,7 @@
ios_interface: ios_interface:
name: "{{ test_interface }}" name: "{{ test_interface }}"
enabled: False enabled: False
authorize: yes provider: "{{ cli }}"
state: up state: up
ignore_errors: yes ignore_errors: yes
register: result register: result
@ -61,7 +61,7 @@
ios_command: ios_command:
commands: commands:
- show lldp neighbors - show lldp neighbors
authorize: yes provider: "{{ cli }}"
register: show_lldp_neighbors_result register: show_lldp_neighbors_result
- block: - block:
@ -71,7 +71,7 @@
neighbors: neighbors:
- port: eth0 - port: eth0
host: netdev host: netdev
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -84,7 +84,7 @@
neighbors: neighbors:
- port: dummy_port - port: dummy_port
host: dummy_host host: dummy_host
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
register: result register: result
@ -101,7 +101,7 @@
- name: "{{ test_interface }}" - name: "{{ test_interface }}"
enabled: True enabled: True
state: up state: up
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
register: result register: result
@ -117,7 +117,7 @@
neighbors: neighbors:
- port: eth0 - port: eth0
host: netdev host: netdev
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
register: result register: result
@ -134,7 +134,7 @@
host: netdev host: netdev
- port: dummy_port - port: dummy_port
host: dummy_host host: dummy_host
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
register: result register: result

View file

@ -11,7 +11,7 @@
speed: 1000 speed: 1000
mtu: 1800 mtu: 1800
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: Configure interface using platform agnostic module - name: Configure interface using platform agnostic module
@ -19,7 +19,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
description: test-interface-initial description: test-interface-initial
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -34,7 +34,7 @@
description: test-interface description: test-interface
mtu: 2000 mtu: 2000
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -5,7 +5,7 @@
ios_l3_interface: ios_l3_interface:
name: "{{ test_interface }}" name: "{{ test_interface }}"
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: Setup - Ensure interfaces are switchport - name: Setup - Ensure interfaces are switchport
@ -14,6 +14,7 @@
- no shutdown - no shutdown
parents: parents:
- "interface {{ item }}" - "interface {{ item }}"
provider: "{{ cli }}"
loop: loop:
- "{{ test_interface }}" - "{{ test_interface }}"
- "{{ test_interface2 }}" - "{{ test_interface2 }}"
@ -23,7 +24,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
ipv4: 192.168.0.1/24 ipv4: 192.168.0.1/24
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -37,7 +38,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
ipv4: 192.168.0.1/24 ipv4: 192.168.0.1/24
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -49,7 +50,7 @@
name: "{{ test_interface2 }}" name: "{{ test_interface2 }}"
ipv4: 192.168.0.1/24 ipv4: 192.168.0.1/24
state: present state: present
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
register: result register: result
@ -63,7 +64,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
ipv4: dhcp ipv4: dhcp
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -77,7 +78,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
ipv6: fd5d:12c9:2201:1::1/64 ipv6: fd5d:12c9:2201:1::1/64
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -91,7 +92,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
ipv6: fd5d:12c9:2201:1::1/64 ipv6: fd5d:12c9:2201:1::1/64
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -103,7 +104,7 @@
name: "{{ test_interface2 }}" name: "{{ test_interface2 }}"
ipv6: fd5d:12c9:2201:1::1/64 ipv6: fd5d:12c9:2201:1::1/64
state: present state: present
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
register: result register: result
@ -117,7 +118,7 @@
name: "{{ test_interface }}" name: "{{ test_interface }}"
ipv6: dhcp ipv6: dhcp
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -130,7 +131,7 @@
ios_l3_interface: ios_l3_interface:
name: "{{ test_interface }}" name: "{{ test_interface }}"
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -144,14 +145,14 @@
ios_l3_interface: ios_l3_interface:
name: "{{ test_interface }}" name: "{{ test_interface }}"
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: Delete second interface ipv4 and ipv6 address (setup) - name: Delete second interface ipv4 and ipv6 address (setup)
ios_l3_interface: ios_l3_interface:
name: "{{ test_interface2 }}" name: "{{ test_interface2 }}"
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: Configure ipv4 and ipv6 address using aggregate - name: Configure ipv4 and ipv6 address using aggregate
@ -159,7 +160,7 @@
aggregate: aggregate:
- { name: "{{ test_interface }}", ipv4: 192.161.0.1/24, ipv6: "fd5d:12c9:2201:2::2/64" } - { name: "{{ test_interface }}", ipv4: 192.161.0.1/24, ipv6: "fd5d:12c9:2201:2::2/64" }
- { name: "{{ test_interface2 }}", ipv4: 192.162.0.2/16, ipv6: "fd5e:12c9:2201:3::3/32" } - { name: "{{ test_interface2 }}", ipv4: 192.162.0.2/16, ipv6: "fd5e:12c9:2201:3::3/32" }
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -177,7 +178,7 @@
aggregate: aggregate:
- { name: "{{ test_interface }}", ipv4: 192.161.0.1/24, ipv6: "fd5d:12c9:2201:2::2/64" } - { name: "{{ test_interface }}", ipv4: 192.161.0.1/24, ipv6: "fd5d:12c9:2201:2::2/64" }
- { name: "{{ test_interface2 }}", ipv4: 192.162.0.2/16, ipv6: "fd5e:12c9:2201:3::3/32" } - { name: "{{ test_interface2 }}", ipv4: 192.162.0.2/16, ipv6: "fd5e:12c9:2201:3::3/32" }
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -189,7 +190,7 @@
aggregate: aggregate:
- { name: "{{ test_interface }}", ipv4: 193.167.1.1/8, ipv6: "fd5a:12c9:2201:4::4/32" } - { name: "{{ test_interface }}", ipv4: 193.167.1.1/8, ipv6: "fd5a:12c9:2201:4::4/32" }
- { name: "{{ test_interface2 }}", ipv4: 192.169.2.2/24, ipv6: "fd5b:12c9:2201:5::5/90" } - { name: "{{ test_interface2 }}", ipv4: 192.169.2.2/24, ipv6: "fd5b:12c9:2201:5::5/90" }
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -209,7 +210,7 @@
- { name: "{{ test_interface }}" } - { name: "{{ test_interface }}" }
- { name: "{{ test_interface2 }}" } - { name: "{{ test_interface2 }}" }
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -228,7 +229,7 @@
- { name: "{{ test_interface }}" } - { name: "{{ test_interface }}" }
- { name: "{{ test_interface2 }}" } - { name: "{{ test_interface2 }}" }
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -9,21 +9,21 @@
ios_config: ios_config:
lines: lines:
- no interface port-channel 20 - no interface port-channel 20
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: setup - remove config used in test(part2) - name: setup - remove config used in test(part2)
ios_config: ios_config:
lines: lines:
- no interface port-channel 5 - no interface port-channel 5
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: setup - remove config used in test(part3) - name: setup - remove config used in test(part3)
ios_config: ios_config:
lines: lines:
- no channel-group 20 mode active - no channel-group 20 mode active
authorize: yes provider: "{{ cli }}"
parents: "{{ item }}" parents: "{{ item }}"
loop: loop:
- interface GigabitEthernet0/1 - interface GigabitEthernet0/1
@ -33,7 +33,7 @@
ios_linkagg: &create ios_linkagg: &create
group: 20 group: 20
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -56,7 +56,7 @@
members: members:
- GigabitEthernet0/1 - GigabitEthernet0/1
- GigabitEthernet0/2 - GigabitEthernet0/2
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -81,7 +81,7 @@
mode: active mode: active
members: members:
- GigabitEthernet0/2 - GigabitEthernet0/2
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -102,7 +102,7 @@
ios_linkagg: &remove ios_linkagg: &remove
group: 20 group: 20
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -123,7 +123,7 @@
aggregate: aggregate:
- { group: 5 } - { group: 5 }
- { group: 20, mode: active, members: ['GigabitEthernet0/1'] } - { group: 20, mode: active, members: ['GigabitEthernet0/1'] }
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -146,21 +146,21 @@
ios_config: ios_config:
lines: lines:
- no interface port-channel 20 - no interface port-channel 20
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: teardown(part2) - name: teardown(part2)
ios_config: ios_config:
lines: lines:
- no interface port-channel 5 - no interface port-channel 5
authorize: yes provider: "{{ cli }}"
ignore_errors: yes ignore_errors: yes
- name: teardown(part3) - name: teardown(part3)
ios_config: ios_config:
lines: lines:
- no channel-group 20 mode active - no channel-group 20 mode active
authorize: yes provider: "{{ cli }}"
parents: "{{ item }}" parents: "{{ item }}"
loop: loop:
- interface GigabitEthernet0/1 - interface GigabitEthernet0/1

View file

@ -4,12 +4,12 @@
- name: Make sure LLDP is not running before tests - name: Make sure LLDP is not running before tests
ios_config: ios_config:
lines: no lldp run lines: no lldp run
authorize: yes provider: "{{ cli }}"
- name: Enable LLDP service - name: Enable LLDP service
ios_lldp: ios_lldp:
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -20,7 +20,7 @@
- name: Enable LLDP service again (idempotent) - name: Enable LLDP service again (idempotent)
ios_lldp: ios_lldp:
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -30,7 +30,7 @@
- name: Disable LLDP service - name: Disable LLDP service
ios_lldp: ios_lldp:
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -41,7 +41,7 @@
- name: Disable LLDP service (idempotent) - name: Disable LLDP service (idempotent)
ios_lldp: ios_lldp:
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -5,20 +5,20 @@
dest: host dest: host
name: 172.16.0.1 name: 172.16.0.1
state: absent state: absent
authorize: yes provider: "{{ cli }}"
- name: Remove console - name: Remove console
ios_logging: ios_logging:
dest: console dest: console
level: warnings level: warnings
state: absent state: absent
authorize: yes provider: "{{ cli }}"
- name: Remove buffer - name: Remove buffer
ios_logging: ios_logging:
dest: buffered dest: buffered
size: 8000 size: 8000
authorize: yes provider: "{{ cli }}"
state: absent state: absent
# start tests # start tests
@ -28,7 +28,7 @@
name: 172.16.0.1 name: 172.16.0.1
facility: local7 facility: local7
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -42,7 +42,7 @@
dest: host dest: host
name: 172.16.0.1 name: 172.16.0.1
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -54,7 +54,7 @@
dest: host dest: host
name: 172.16.0.1 name: 172.16.0.1
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -67,7 +67,7 @@
dest: host dest: host
name: 172.16.0.1 name: 172.16.0.1
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -79,7 +79,7 @@
dest: console dest: console
level: warnings level: warnings
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -91,7 +91,7 @@
ios_logging: ios_logging:
dest: buffered dest: buffered
size: 8000 size: 8000
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -104,7 +104,7 @@
aggregate: aggregate:
- { dest: console, level: notifications } - { dest: console, level: notifications }
- { dest: buffered, size: 9000 } - { dest: buffered, size: 9000 }
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -119,7 +119,7 @@
- { dest: console, level: notifications } - { dest: console, level: notifications }
- { dest: buffered, size: 9000 } - { dest: buffered, size: 9000 }
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -9,7 +9,7 @@
dest: host dest: host
name: 172.16.0.1 name: 172.16.0.1
state: absent state: absent
authorize: yes provider: "{{ cli }}"
- name: Set up host logging using platform agnostic module - name: Set up host logging using platform agnostic module
net_logging: net_logging:
@ -17,7 +17,7 @@
name: 172.16.0.1 name: 172.16.0.1
facility: local7 facility: local7
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -31,6 +31,6 @@
dest: host dest: host
name: 172.16.0.1 name: 172.16.0.1
state: absent state: absent
authorize: yes provider: "{{ cli }}"
- debug: msg="END ios cli/net_logging.yaml on connection={{ ansible_connection }}" - debug: msg="END ios cli/net_logging.yaml on connection={{ ansible_connection }}"

View file

@ -3,7 +3,7 @@
- ios_command: - ios_command:
commands: show version commands: show version
authorize: yes provider: "{{ cli }}"
register: show_version_result register: show_version_result
- set_fact: management_interface=GigabitEthernet0/0 - set_fact: management_interface=GigabitEthernet0/0
@ -16,7 +16,7 @@
ios_command: ios_command:
commands: commands:
- "show ip interface {{ management_interface }} | include Internet address" - "show ip interface {{ management_interface }} | include Internet address"
authorize: yes provider: "{{ cli }}"
register: show_ip_interface_result register: show_ip_interface_result
- name: Extract the IP address from registered output - name: Extract the IP address from registered output
@ -25,14 +25,14 @@
- name: expected successful ping - name: expected successful ping
ios_ping: &valid_ip ios_ping: &valid_ip
dest: '{{ management_ip }}' dest: '{{ management_ip }}'
authorize: yes provider: "{{ cli }}"
register: esp register: esp
- name: unexpected unsuccessful ping - name: unexpected unsuccessful ping
ios_ping: &invalid_ip ios_ping: &invalid_ip
dest: '10.255.255.250' dest: '10.255.255.250'
timeout: 45 timeout: 45
authorize: yes provider: "{{ cli }}"
register: uup register: uup
ignore_errors: yes ignore_errors: yes

View file

@ -8,7 +8,7 @@
next_hop: 10.0.0.8 next_hop: 10.0.0.8
admin_distance: 1 admin_distance: 1
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: create static route - name: create static route
@ -17,7 +17,7 @@
mask: 255.255.255.0 mask: 255.255.255.0
next_hop: 10.0.0.8 next_hop: 10.0.0.8
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -31,7 +31,7 @@
mask: 255.255.255.0 mask: 255.255.255.0
next_hop: 10.0.0.8 next_hop: 10.0.0.8
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -45,7 +45,7 @@
next_hop: 10.0.0.8 next_hop: 10.0.0.8
admin_distance: 2 admin_distance: 2
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -60,7 +60,7 @@
next_hop: 10.0.0.8 next_hop: 10.0.0.8
admin_distance: 2 admin_distance: 2
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -74,7 +74,7 @@
next_hop: 10.0.0.8 next_hop: 10.0.0.8
admin_distance: 2 admin_distance: 2
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -89,7 +89,7 @@
next_hop: 10.0.0.8 next_hop: 10.0.0.8
admin_distance: 2 admin_distance: 2
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -102,7 +102,7 @@
- { prefix: 172.16.32.0, mask: 255.255.255.0, next_hop: 10.0.0.8 } - { prefix: 172.16.32.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
- { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8 } - { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -117,7 +117,7 @@
- { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8, state: absent } - { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8, state: absent }
- { prefix: 172.16.34.0, mask: 255.255.255.0, next_hop: 10.0.0.8 } - { prefix: 172.16.34.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -132,7 +132,7 @@
- { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8 } - { prefix: 172.16.33.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
- { prefix: 172.16.34.0, mask: 255.255.255.0, next_hop: 10.0.0.8 } - { prefix: 172.16.34.0, mask: 255.255.255.0, next_hop: 10.0.0.8 }
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:

View file

@ -11,7 +11,7 @@
next_hop: 10.0.0.8 next_hop: 10.0.0.8
admin_distance: 1 admin_distance: 1
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: create static route using platform agnostic module - name: create static route using platform agnostic module
@ -20,7 +20,7 @@
mask: 255.255.255.0 mask: 255.255.255.0
next_hop: 10.0.0.8 next_hop: 10.0.0.8
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -35,7 +35,7 @@
next_hop: 10.0.0.8 next_hop: 10.0.0.8
admin_distance: 2 admin_distance: 2
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- debug: msg="END ios cli/net_static_route.yaml on connection={{ ansible_connection }}" - debug: msg="END ios cli/net_static_route.yaml on connection={{ ansible_connection }}"

View file

@ -10,14 +10,14 @@
- no ip domain-list ansible.com - no ip domain-list ansible.com
- no ip domain-list redhat.com - no ip domain-list redhat.com
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure domain_search using platform agnostic module - name: configure domain_search using platform agnostic module
net_system: net_system:
domain_search: domain_search:
- ansible.com - ansible.com
- redhat.com - redhat.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -32,6 +32,6 @@
- no ip domain-list ansible.com - no ip domain-list ansible.com
- no ip domain-list redhat.com - no ip domain-list redhat.com
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END ios cli/net_system.yaml on connection={{ ansible_connection }}" - debug: msg="END ios cli/net_system.yaml on connection={{ ansible_connection }}"

View file

@ -7,14 +7,14 @@
- no ip domain-list ansible.com - no ip domain-list ansible.com
- no ip domain-list redhat.com - no ip domain-list redhat.com
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure domain_search - name: configure domain_search
ios_system: ios_system:
domain_search: domain_search:
- ansible.com - ansible.com
- redhat.com - redhat.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -28,7 +28,7 @@
domain_search: domain_search:
- ansible.com - ansible.com
- redhat.com - redhat.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -39,7 +39,7 @@
ios_system: ios_system:
domain_search: domain_search:
- ansible.com - ansible.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -51,7 +51,7 @@
ios_system: ios_system:
domain_search: domain_search:
- ansible.com - ansible.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -63,7 +63,7 @@
domain_search: domain_search:
- ansible.com - ansible.com
- redhat.com - redhat.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -76,7 +76,7 @@
domain_search: domain_search:
- ansible.com - ansible.com
- redhat.com - redhat.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -88,7 +88,7 @@
domain_search: domain_search:
- ansible.com - ansible.com
- eng.ansible.com - eng.ansible.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -103,7 +103,7 @@
domain_search: domain_search:
- ansible.com - ansible.com
- eng.ansible.com - eng.ansible.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -117,6 +117,6 @@
- no ip domain-list redhat.com - no ip domain-list redhat.com
- no ip domain-list eng.ansible.com - no ip domain-list eng.ansible.com
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/set_domain_search.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/set_domain_search.yaml on connection={{ ansible_connection }}"

View file

@ -5,12 +5,12 @@
ios_config: ios_config:
lines: no ip domain-name lines: no ip domain-name
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure domain_name - name: configure domain_name
ios_system: ios_system:
domain_name: eng.ansible.com domain_name: eng.ansible.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -20,7 +20,7 @@
- name: verify domain_name - name: verify domain_name
ios_system: ios_system:
domain_name: eng.ansible.com domain_name: eng.ansible.com
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -31,6 +31,6 @@
ios_config: ios_config:
lines: no ip domain-name lines: no ip domain-name
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/set_domain_name.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/set_domain_name.yaml on connection={{ ansible_connection }}"

View file

@ -5,12 +5,12 @@
ios_config: ios_config:
lines: hostname switch lines: hostname switch
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure hostname - name: configure hostname
ios_system: ios_system:
hostname: foo hostname: foo
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -20,7 +20,7 @@
- name: verify hostname - name: verify hostname
ios_system: ios_system:
hostname: foo hostname: foo
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -31,6 +31,6 @@
ios_config: ios_config:
lines: "hostname {{ inventory_hostname }}" lines: "hostname {{ inventory_hostname }}"
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/set_hostname.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/set_hostname.yaml on connection={{ ansible_connection }}"

View file

@ -7,12 +7,12 @@
- no ip domain lookup source-interface Loopback888 - no ip domain lookup source-interface Loopback888
- vrf definition ansible - vrf definition ansible
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure lookup_source - name: configure lookup_source
ios_system: ios_system:
lookup_source: Loopback888 lookup_source: Loopback888
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -23,7 +23,7 @@
- name: verify lookup_source - name: verify lookup_source
ios_system: ios_system:
lookup_source: Loopback888 lookup_source: Loopback888
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -33,7 +33,7 @@
- name: Disable lookup_source - name: Disable lookup_source
ios_system: ios_system:
lookup_enabled: False lookup_enabled: False
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -44,7 +44,7 @@
- name: Disable lookup_source - name: Disable lookup_source
ios_system: ios_system:
lookup_enabled: True lookup_enabled: True
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -57,7 +57,7 @@
# lookup_source: # lookup_source:
# - interface: Loopback10 # - interface: Loopback10
# vrf: ansible # vrf: ansible
# authorize: yes # provider: "{{ cli }}"
# provider: "{{ cli }}" # provider: "{{ cli }}"
# register: result # register: result
# #
@ -73,7 +73,7 @@
# lookup_source: # lookup_source:
# - interface: Management1 # - interface: Management1
# vrf: ansible # vrf: ansible
# authorize: yes # provider: "{{ cli }}"
# provider: "{{ cli }}" # provider: "{{ cli }}"
# register: result # register: result
# #
@ -87,7 +87,7 @@
- no ip domain lookup source-interface Loopback888 - no ip domain lookup source-interface Loopback888
- no vrf definition ansible - no vrf definition ansible
match: none match: none
authorize: yes provider: "{{ cli }}"
ignore_errors: yes 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 # 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

View file

@ -6,7 +6,7 @@
lines: lines:
- no ip name-server - no ip name-server
match: none match: none
authorize: yes provider: "{{ cli }}"
- name: configure name_servers - name: configure name_servers
ios_system: ios_system:
@ -14,7 +14,7 @@
- 1.1.1.1 - 1.1.1.1
- 2.2.2.2 - 2.2.2.2
- 3.3.3.3 - 3.3.3.3
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -31,7 +31,7 @@
- 1.1.1.1 - 1.1.1.1
- 2.2.2.2 - 2.2.2.2
- 3.3.3.3 - 3.3.3.3
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -72,7 +72,7 @@
name_servers: name_servers:
- 1.1.1.1 - 1.1.1.1
- 2.2.2.2 - 2.2.2.2
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -86,6 +86,6 @@
lines: lines:
- no ip name-server - no ip name-server
match: none match: none
authorize: yes provider: "{{ cli }}"
- debug: msg="END cli/set_name_servers.yaml on connection={{ ansible_connection }}" - debug: msg="END cli/set_name_servers.yaml on connection={{ ansible_connection }}"

View file

@ -6,7 +6,7 @@
privilege: 15 privilege: 15
role: network-operator role: network-operator
state: present state: present
authorize: yes provider: "{{ cli }}"
configured_password: pass123 configured_password: pass123
- name: test login - name: test login
@ -33,7 +33,7 @@
ios_user: ios_user:
name: auth_user name: auth_user
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- name: reset connection - name: reset connection

View file

@ -6,7 +6,7 @@
- name: ansibletest2 - name: ansibletest2
- name: ansibletest3 - name: ansibletest3
state: absent state: absent
authorize: yes provider: "{{ cli }}"
- name: Create user (SetUp) - name: Create user (SetUp)
ios_user: ios_user:
@ -14,7 +14,7 @@
privilege: 15 privilege: 15
role: network-operator role: network-operator
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -27,7 +27,7 @@
aggregate: aggregate:
- name: ansibletest2 - name: ansibletest2
- name: ansibletest3 - name: ansibletest3
authorize: yes provider: "{{ cli }}"
state: present state: present
view: network-admin view: network-admin
register: result register: result
@ -43,7 +43,7 @@
privilege: 15 privilege: 15
role: network-operator role: network-operator
state: present state: present
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -56,7 +56,7 @@
aggregate: aggregate:
- name: ansibletest2 - name: ansibletest2
- name: ansibletest3 - name: ansibletest3
authorize: yes provider: "{{ cli }}"
state: present state: present
view: network-admin view: network-admin
register: result register: result
@ -73,12 +73,12 @@
- name: ansibletest2 - name: ansibletest2
- name: ansibletest3 - name: ansibletest3
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
that: that:
- 'result.changed == true' - 'result.changed == true'
- '"no username ansibletest1" in result.commands[0]' - '"no username ansibletest1" in result.commands[0]["command"]'
- '"no username ansibletest2" in result.commands[1]' - '"no username ansibletest2" in result.commands[1]["command"]'
- '"no username ansibletest3" in result.commands[2]' - '"no username ansibletest3" in result.commands[2]["command"]'

View file

@ -11,14 +11,14 @@
- no vlan 100 - no vlan 100
- no vlan 200 - no vlan 200
- no vlan 300 - no vlan 300
authorize: yes provider: "{{ cli }}"
- name: setup - remove switchport settings on interfaces used in test - name: setup - remove switchport settings on interfaces used in test
ios_config: ios_config:
lines: lines:
- switchport mode access - switchport mode access
- no switchport access vlan 100 - no switchport access vlan 100
authorize: yes provider: "{{ cli }}"
parents: "{{ item }}" parents: "{{ item }}"
loop: loop:
- interface GigabitEthernet0/1 - interface GigabitEthernet0/1
@ -28,7 +28,7 @@
ios_vlan: &create ios_vlan: &create
vlan_id: 100 vlan_id: 100
name: test-vlan name: test-vlan
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -51,7 +51,7 @@
interfaces: interfaces:
- GigabitEthernet0/1 - GigabitEthernet0/1
- GigabitEthernet0/2 - GigabitEthernet0/2
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -77,7 +77,7 @@
vlan_id: 100 vlan_id: 100
interfaces: interfaces:
- GigabitEthernet0/1 - GigabitEthernet0/1
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -100,7 +100,7 @@
ios_vlan: ios_vlan:
vlan_id: 100 vlan_id: 100
state: suspend state: suspend
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -113,7 +113,7 @@
ios_vlan: ios_vlan:
vlan_id: 100 vlan_id: 100
state: active state: active
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -125,7 +125,7 @@
- name: delete vlan - name: delete vlan
ios_vlan: &delete ios_vlan: &delete
vlan_id: 100 vlan_id: 100
authorize: yes provider: "{{ cli }}"
state: absent state: absent
register: result register: result
@ -147,7 +147,7 @@
aggregate: aggregate:
- { vlan_id: 200, name: vlan-200 } - { vlan_id: 200, name: vlan-200 }
- { vlan_id: 300, name: vlan-300 } - { vlan_id: 300, name: vlan-300 }
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -172,7 +172,7 @@
- { vlan_id: 200, name: vlan-200 } - { vlan_id: 200, name: vlan-200 }
- { vlan_id: 300, name: vlan-300 } - { vlan_id: 300, name: vlan-300 }
state: absent state: absent
authorize: yes provider: "{{ cli }}"
register: result register: result
- assert: - assert:
@ -195,14 +195,14 @@
- no vlan 100 - no vlan 100
- no vlan 200 - no vlan 200
- no vlan 300 - no vlan 300
authorize: yes provider: "{{ cli }}"
- name: teardown(part2) - name: teardown(part2)
ios_config: ios_config:
lines: lines:
- switchport mode access - switchport mode access
- no switchport access vlan 100 - no switchport access vlan 100
authorize: yes provider: "{{ cli }}"
parents: "{{ item }}" parents: "{{ item }}"
loop: loop:
- interface GigabitEthernet0/1 - interface GigabitEthernet0/1

View file

@ -57,15 +57,14 @@ class TestIosUserModule(TestIosModule):
def test_ios_user_delete(self): def test_ios_user_delete(self):
set_module_args(dict(name='ansible', state='absent')) set_module_args(dict(name='ansible', state='absent'))
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
cmd = json.loads( cmd = {
'{"answer": "y", "newline": false, ' + "command": "no username ansible", "answer": "y", "newline": False,
'"prompt": "This operation will remove all username related ' + "prompt": "This operation will remove all username related configurations with same name",
'configurations with same name", "command": "no username ansible"}' }
)
result_cmd = [] result_cmd = []
for i in result['commands']: for i in result['commands']:
result_cmd.append(json.loads(i)) result_cmd.append(i)
self.assertEqual(result_cmd, [cmd]) self.assertEqual(result_cmd, [cmd])
@ -86,15 +85,14 @@ class TestIosUserModule(TestIosModule):
def test_ios_user_purge(self): def test_ios_user_purge(self):
set_module_args(dict(purge=True)) set_module_args(dict(purge=True))
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
cmd = json.loads( cmd = {
'{"answer": "y", "newline": false, ' + "command": "no username ansible", "answer": "y", "newline": False,
'"prompt": "This operation will remove all username related ' + "prompt": "This operation will remove all username related configurations with same name",
'configurations with same name", "command": "no username ansible"}' }
)
result_cmd = [] result_cmd = []
for i in result['commands']: for i in result['commands']:
result_cmd.append(json.loads(i)) result_cmd.append(i)
self.assertEqual(result_cmd, [cmd]) self.assertEqual(result_cmd, [cmd])