mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
ios integration tests to network_cli (#33920)
* Preliminary steps * Fix Python3 network_cli ios * Add connection to debug strings * Fix ios confirm prompt by way of optional newline Also update ios_user delete tests
This commit is contained in:
parent
8d5c8b252d
commit
cb1b705218
56 changed files with 358 additions and 102 deletions
|
@ -181,7 +181,8 @@ def user_del_cmd(username):
|
||||||
return json.dumps({
|
return json.dumps({
|
||||||
'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,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ class ActionModule(_ActionModule):
|
||||||
try:
|
try:
|
||||||
self._handle_template()
|
self._handle_template()
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
return dict(failed=True, msg=exc.message)
|
return dict(failed=True, msg=to_text(exc))
|
||||||
|
|
||||||
result = super(ActionModule, self).run(tmp, task_vars)
|
result = super(ActionModule, self).run(tmp, task_vars)
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class ActionModule(_ActionModule):
|
||||||
|
|
||||||
# strip out any keys that have two leading and two trailing
|
# strip out any keys that have two leading and two trailing
|
||||||
# underscore characters
|
# underscore characters
|
||||||
for key in result.keys():
|
for key in list(result.keys()):
|
||||||
if PRIVATE_KEYS_RE.match(key):
|
if PRIVATE_KEYS_RE.match(key):
|
||||||
del result[key]
|
del result[key]
|
||||||
|
|
||||||
|
|
|
@ -64,8 +64,8 @@ class Cliconf(CliconfBase):
|
||||||
|
|
||||||
@enable_mode
|
@enable_mode
|
||||||
def edit_config(self, command):
|
def edit_config(self, command):
|
||||||
for cmd in chain([b'configure terminal'], to_list(command), [b'end']):
|
for cmd in chain(['configure terminal'], to_list(command), ['end']):
|
||||||
self.send_command(cmd)
|
self.send_command(to_bytes(cmd))
|
||||||
|
|
||||||
def get(self, command, prompt=None, answer=None, sendonly=False):
|
def get(self, command, prompt=None, answer=None, sendonly=False):
|
||||||
return self.send_command(command, prompt=prompt, answer=answer, sendonly=sendonly)
|
return self.send_command(command, prompt=prompt, answer=answer, sendonly=sendonly)
|
||||||
|
|
|
@ -121,8 +121,10 @@ class Connection(ConnectionBase):
|
||||||
try:
|
try:
|
||||||
cmd = json.loads(to_text(cmd, errors='surrogate_or_strict'))
|
cmd = json.loads(to_text(cmd, errors='surrogate_or_strict'))
|
||||||
kwargs = {'command': to_bytes(cmd['command'], errors='surrogate_or_strict')}
|
kwargs = {'command': to_bytes(cmd['command'], errors='surrogate_or_strict')}
|
||||||
for key in ('prompt', 'answer', 'sendonly'):
|
for key in ('prompt', 'answer', 'sendonly', 'newline'):
|
||||||
if cmd.get(key) is not None:
|
if cmd.get(key) is True or cmd.get(key) is False:
|
||||||
|
kwargs[key] = cmd[key]
|
||||||
|
elif cmd.get(key) is not None:
|
||||||
kwargs[key] = to_bytes(cmd[key], errors='surrogate_or_strict')
|
kwargs[key] = to_bytes(cmd[key], errors='surrogate_or_strict')
|
||||||
return self.send(**kwargs)
|
return self.send(**kwargs)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
@ -257,7 +259,7 @@ class Connection(ConnectionBase):
|
||||||
self._connected = False
|
self._connected = False
|
||||||
display.debug("ssh connection has been closed successfully")
|
display.debug("ssh connection has been closed successfully")
|
||||||
|
|
||||||
def receive(self, command=None, prompts=None, answer=None):
|
def receive(self, command=None, prompts=None, answer=None, newline=True):
|
||||||
'''
|
'''
|
||||||
Handles receiving of output from command
|
Handles receiving of output from command
|
||||||
'''
|
'''
|
||||||
|
@ -279,14 +281,14 @@ class Connection(ConnectionBase):
|
||||||
|
|
||||||
window = self._strip(recv.read())
|
window = self._strip(recv.read())
|
||||||
if prompts and not handled:
|
if prompts and not handled:
|
||||||
handled = self._handle_prompt(window, prompts, answer)
|
handled = self._handle_prompt(window, prompts, answer, newline)
|
||||||
|
|
||||||
if self._find_prompt(window):
|
if self._find_prompt(window):
|
||||||
self._last_response = recv.getvalue()
|
self._last_response = recv.getvalue()
|
||||||
resp = self._strip(self._last_response)
|
resp = self._strip(self._last_response)
|
||||||
return self._sanitize(resp, command)
|
return self._sanitize(resp, command)
|
||||||
|
|
||||||
def send(self, command, prompt=None, answer=None, sendonly=False):
|
def send(self, command, prompt=None, answer=None, newline=True, sendonly=False):
|
||||||
'''
|
'''
|
||||||
Sends the command to the device in the opened shell
|
Sends the command to the device in the opened shell
|
||||||
'''
|
'''
|
||||||
|
@ -295,7 +297,7 @@ class Connection(ConnectionBase):
|
||||||
self._ssh_shell.sendall(b'%s\r' % command)
|
self._ssh_shell.sendall(b'%s\r' % command)
|
||||||
if sendonly:
|
if sendonly:
|
||||||
return
|
return
|
||||||
response = self.receive(command, prompt, answer)
|
response = self.receive(command, prompt, answer, newline)
|
||||||
return to_text(response, errors='surrogate_or_strict')
|
return to_text(response, errors='surrogate_or_strict')
|
||||||
except (socket.timeout, AttributeError):
|
except (socket.timeout, AttributeError):
|
||||||
display.vvvv(traceback.format_exc(), host=self._play_context.remote_addr)
|
display.vvvv(traceback.format_exc(), host=self._play_context.remote_addr)
|
||||||
|
@ -309,7 +311,7 @@ class Connection(ConnectionBase):
|
||||||
data = regex.sub(b'', data)
|
data = regex.sub(b'', data)
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def _handle_prompt(self, resp, prompts, answer):
|
def _handle_prompt(self, resp, prompts, answer, newline):
|
||||||
'''
|
'''
|
||||||
Matches the command prompt and responds
|
Matches the command prompt and responds
|
||||||
|
|
||||||
|
@ -325,7 +327,9 @@ class Connection(ConnectionBase):
|
||||||
for regex in prompts:
|
for regex in prompts:
|
||||||
match = regex.search(resp)
|
match = regex.search(resp)
|
||||||
if match:
|
if match:
|
||||||
self._ssh_shell.sendall(b'%s\r' % answer)
|
self._ssh_shell.sendall(b'%s' % answer)
|
||||||
|
if newline:
|
||||||
|
self._ssh_shell.sendall(b'\r')
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,19 @@
|
||||||
paths: "{{ role_path }}/tests/cli"
|
paths: "{{ role_path }}/tests/cli"
|
||||||
patterns: "{{ testcase }}.yaml"
|
patterns: "{{ testcase }}.yaml"
|
||||||
register: test_cases
|
register: test_cases
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
banner: login
|
banner: login
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: Set login
|
- name: Set login
|
||||||
ios_banner:
|
ios_banner:
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
string
|
string
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
|
@ -34,6 +36,7 @@
|
||||||
string
|
string
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
banner: motd
|
banner: motd
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: Set motd
|
- name: Set motd
|
||||||
ios_banner:
|
ios_banner:
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
string
|
string
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
|
@ -34,6 +36,7 @@
|
||||||
string
|
string
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
|
|
@ -7,12 +7,14 @@
|
||||||
over multiple lines
|
over multiple lines
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: remove login
|
- name: remove login
|
||||||
ios_banner:
|
ios_banner:
|
||||||
banner: login
|
banner: login
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug:
|
- debug:
|
||||||
|
@ -28,6 +30,7 @@
|
||||||
banner: login
|
banner: login
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
|
|
@ -9,8 +9,14 @@
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/bad_operator.yaml"
|
- debug: msg="START cli/bad_operator.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: test bad operator
|
- name: test bad operator
|
||||||
ios_command:
|
ios_command:
|
||||||
|
@ -9,6 +9,7 @@
|
||||||
authorize: yes
|
authorize: yes
|
||||||
wait_for:
|
wait_for:
|
||||||
- "result[0] contains 'Description: Foo'"
|
- "result[0] contains 'Description: Foo'"
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
|
@ -17,4 +18,4 @@
|
||||||
- "result.failed == true"
|
- "result.failed == true"
|
||||||
- "result.msg is defined"
|
- "result.msg is defined"
|
||||||
|
|
||||||
- debug: msg="END cli/bad_operator.yaml"
|
- debug: msg="END cli/bad_operator.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/contains.yaml"
|
- debug: msg="START cli/contains.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: test contains operator
|
- name: test contains operator
|
||||||
ios_command:
|
ios_command:
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
wait_for:
|
wait_for:
|
||||||
- "result[0] contains Cisco"
|
- "result[0] contains Cisco"
|
||||||
- "result[1] contains Loopback888"
|
- "result[1] contains Loopback888"
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -17,4 +18,4 @@
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
- "result.stdout is defined"
|
- "result.stdout is defined"
|
||||||
|
|
||||||
- debug: msg="END cli/contains.yaml"
|
- debug: msg="END cli/contains.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/invalid.yaml"
|
- debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: run invalid command
|
- name: run invalid command
|
||||||
ios_command:
|
ios_command:
|
||||||
commands: show foo
|
commands: show foo
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
|
@ -18,6 +19,7 @@
|
||||||
- show version
|
- show version
|
||||||
- show foo
|
- show foo
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
|
@ -25,4 +27,4 @@
|
||||||
that:
|
that:
|
||||||
- "result.failed"
|
- "result.failed"
|
||||||
|
|
||||||
- debug: msg="END cli/invalid.yaml"
|
- debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/output.yaml"
|
- debug: msg="START cli/output.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: get output for single command
|
- name: get output for single command
|
||||||
ios_command:
|
ios_command:
|
||||||
commands:
|
commands:
|
||||||
- show version
|
- show version
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -19,6 +20,7 @@
|
||||||
- show version
|
- show version
|
||||||
- show interfaces
|
- show interfaces
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -27,4 +29,4 @@
|
||||||
- "result.stdout is defined"
|
- "result.stdout is defined"
|
||||||
- "result.stdout | length == 2"
|
- "result.stdout | length == 2"
|
||||||
|
|
||||||
- debug: msg="END cli/output.yaml"
|
- debug: msg="END cli/output.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/timeout.yaml"
|
- debug: msg="START cli/timeout.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: test bad condition
|
- name: test bad condition
|
||||||
ios_command:
|
ios_command:
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
authorize: yes
|
authorize: yes
|
||||||
wait_for:
|
wait_for:
|
||||||
- "result[0] contains bad_value_string"
|
- "result[0] contains bad_value_string"
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
|
@ -16,4 +17,4 @@
|
||||||
- "result.failed == true"
|
- "result.failed == true"
|
||||||
- "result.msg is defined"
|
- "result.msg is defined"
|
||||||
|
|
||||||
- debug: msg="END cli/timeout.yaml"
|
- debug: msg="END cli/timeout.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -9,8 +9,14 @@
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/backup.yaml"
|
- debug: msg="START cli/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -10,13 +10,14 @@
|
||||||
- interface Loopback999
|
- interface Loopback999
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: collect any backup files
|
- name: collect any backup files
|
||||||
find:
|
find:
|
||||||
paths: "{{ role_path }}/backup"
|
paths: "{{ role_path }}/backup"
|
||||||
pattern: "{{ inventory_hostname_short }}_config*"
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
register: backup_files
|
register: backup_files
|
||||||
delegate_to: localhost
|
connection: local
|
||||||
|
|
||||||
- name: delete backup files
|
- name: delete backup files
|
||||||
file:
|
file:
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
src: basic/config.j2
|
src: basic/config.j2
|
||||||
backup: yes
|
backup: yes
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -42,10 +44,10 @@
|
||||||
paths: "{{ role_path }}/backup"
|
paths: "{{ role_path }}/backup"
|
||||||
pattern: "{{ inventory_hostname_short }}_config*"
|
pattern: "{{ inventory_hostname_short }}_config*"
|
||||||
register: backup_files
|
register: backup_files
|
||||||
delegate_to: localhost
|
connection: local
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- "backup_files.files is defined"
|
- "backup_files.files is defined"
|
||||||
|
|
||||||
- debug: msg="END cli/backup.yaml"
|
- debug: msg="END cli/backup.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/defaults.yaml"
|
- debug: msg="START cli/defaults.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -10,12 +10,14 @@
|
||||||
- interface Loopback999
|
- interface Loopback999
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- 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
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug: var=result
|
- debug: var=result
|
||||||
|
@ -31,6 +33,7 @@
|
||||||
src: defaults/config.j2
|
src: defaults/config.j2
|
||||||
defaults: yes
|
defaults: yes
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug: var=result
|
- debug: var=result
|
||||||
|
@ -45,6 +48,7 @@
|
||||||
lines:
|
lines:
|
||||||
- mac-address-table notification mac-move
|
- mac-address-table notification mac-move
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
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
|
||||||
|
@ -52,6 +56,7 @@
|
||||||
commands:
|
commands:
|
||||||
- show interfaces
|
- show interfaces
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -59,4 +64,4 @@
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
- "result.stdout is defined"
|
- "result.stdout is defined"
|
||||||
|
|
||||||
- debug: msg="END cli/defaults.yaml"
|
- debug: msg="END cli/defaults.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/save.yaml"
|
- debug: msg="START cli/save.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -10,12 +10,14 @@
|
||||||
- interface Loopback999
|
- interface Loopback999
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
|
||||||
- name: save config
|
- name: save config
|
||||||
ios_config:
|
ios_config:
|
||||||
save: true
|
save: true
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
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
|
||||||
|
@ -30,6 +32,7 @@
|
||||||
ios_config:
|
ios_config:
|
||||||
save: true
|
save: true
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
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
|
||||||
|
@ -41,6 +44,7 @@
|
||||||
- "no ip http server"
|
- "no ip http server"
|
||||||
save_when: modified
|
save_when: modified
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: save should always run
|
- name: save should always run
|
||||||
|
@ -50,6 +54,7 @@
|
||||||
- "ip http server"
|
- "ip http server"
|
||||||
save_when: modified
|
save_when: modified
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -61,6 +66,7 @@
|
||||||
lines:
|
lines:
|
||||||
- "no ip http server"
|
- "no ip http server"
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- debug: msg="END cli/save.yaml"
|
- debug: msg="END cli/save.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/src_basic.yaml"
|
- debug: msg="START cli/src_basic.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -10,11 +10,13 @@
|
||||||
- interface Loopback999
|
- interface Loopback999
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure device with config
|
- name: configure device with config
|
||||||
ios_config:
|
ios_config:
|
||||||
src: basic/config.j2
|
src: basic/config.j2
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: debug, remove me
|
- name: debug, remove me
|
||||||
|
@ -31,6 +33,7 @@
|
||||||
ios_config:
|
ios_config:
|
||||||
src: basic/config.j2
|
src: basic/config.j2
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -40,4 +43,4 @@
|
||||||
# FIXME Bug https://github.com/ansible/ansible/issues/19382
|
# FIXME Bug https://github.com/ansible/ansible/issues/19382
|
||||||
# - "result.updates is not defined"
|
# - "result.updates is not defined"
|
||||||
|
|
||||||
- debug: msg="END cli/src_basic.yaml"
|
- debug: msg="END cli/src_basic.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/src_invalid.yaml"
|
- debug: msg="START cli/src_invalid.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
|
||||||
# Defend https://github.com/ansible/ansible-modules-core/issues/4797
|
# Defend https://github.com/ansible/ansible-modules-core/issues/4797
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
ios_config:
|
ios_config:
|
||||||
src: basic/foobar.j2
|
src: basic/foobar.j2
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
|
|
||||||
|
@ -16,4 +17,4 @@
|
||||||
- "result.failed == true"
|
- "result.failed == true"
|
||||||
- "result.msg == 'path specified in src not found'"
|
- "result.msg == 'path specified in src not found'"
|
||||||
|
|
||||||
- debug: msg="END cli/src_invalid.yaml"
|
- debug: msg="END cli/src_invalid.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/src_match_none.yaml"
|
- debug: msg="START cli/src_match_none.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -10,12 +10,14 @@
|
||||||
- interface Loopback999
|
- interface Loopback999
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- 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
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -29,6 +31,7 @@
|
||||||
ios_config:
|
ios_config:
|
||||||
src: basic/config.j2
|
src: basic/config.j2
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -38,4 +41,4 @@
|
||||||
- "result.changed == false"
|
- "result.changed == false"
|
||||||
- "result.updates is not defined"
|
- "result.updates is not defined"
|
||||||
|
|
||||||
- debug: msg="END cli/src_match_none.yaml"
|
- debug: msg="END cli/src_match_none.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/sublevel.yaml"
|
- debug: msg="START cli/sublevel.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup test
|
- name: setup test
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -8,12 +8,14 @@
|
||||||
- 'no ip access-list standard test'
|
- 'no ip access-list standard test'
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- 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
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -27,6 +29,7 @@
|
||||||
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
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -39,5 +42,6 @@
|
||||||
- 'no ip access-list extended test'
|
- 'no ip access-list extended test'
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/sublevel.yaml"
|
- debug: msg="END cli/sublevel.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/sublevel_block.yaml"
|
- debug: msg="START cli/sublevel_block.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -12,6 +12,7 @@
|
||||||
after: ['exit']
|
after: ['exit']
|
||||||
authorize: yes
|
authorize: yes
|
||||||
match: none
|
match: none
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure sub level command using block resplace
|
- name: configure sub level command using block resplace
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
replace: block
|
replace: block
|
||||||
after: ['exit']
|
after: ['exit']
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -46,6 +48,7 @@
|
||||||
replace: block
|
replace: block
|
||||||
after: ['exit']
|
after: ['exit']
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -58,5 +61,6 @@
|
||||||
- no ip access-list extended test
|
- no ip access-list extended test
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/sublevel_block.yaml"
|
- debug: msg="END cli/sublevel_block.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/sublevel_exact.yaml"
|
- debug: msg="START cli/sublevel_exact.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -14,6 +14,7 @@
|
||||||
after: exit
|
after: exit
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure sub level command using exact match
|
- name: configure sub level command using exact match
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -27,6 +28,7 @@
|
||||||
after: exit
|
after: exit
|
||||||
match: exact
|
match: exact
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -49,6 +51,7 @@
|
||||||
parents: ip access-list extended test
|
parents: ip access-list extended test
|
||||||
match: exact
|
match: exact
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -61,5 +64,6 @@
|
||||||
- no ip access-list extended test
|
- no ip access-list extended test
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/sublevel_exact.yaml"
|
- debug: msg="END cli/sublevel_exact.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/sublevel_strict.yaml"
|
- debug: msg="START cli/sublevel_strict.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -13,6 +13,7 @@
|
||||||
before: no ip access-list extended test
|
before: no ip access-list extended test
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure sub level command using strict match
|
- name: configure sub level command using strict match
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
parents: ip access-list extended test
|
parents: ip access-list extended test
|
||||||
match: strict
|
match: strict
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -40,6 +42,7 @@
|
||||||
after: exit
|
after: exit
|
||||||
match: strict
|
match: strict
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -57,5 +60,6 @@
|
||||||
lines: no ip access-list extended test
|
lines: no ip access-list extended test
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/sublevel_strict.yaml"
|
- debug: msg="END cli/sublevel_strict.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/toplevel.yaml"
|
- debug: msg="START cli/toplevel.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
lines: ['hostname {{ shorter_hostname }}']
|
lines: ['hostname {{ shorter_hostname }}']
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure top level command
|
- name: configure top level command
|
||||||
ios_config:
|
ios_config:
|
||||||
lines: ['hostname foo']
|
lines: ['hostname foo']
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -22,6 +24,7 @@
|
||||||
ios_config:
|
ios_config:
|
||||||
lines: ['hostname foo']
|
lines: ['hostname foo']
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -33,5 +36,6 @@
|
||||||
lines: ['hostname {{ shorter_hostname }}']
|
lines: ['hostname {{ shorter_hostname }}']
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/toplevel.yaml"
|
- debug: msg="END cli/toplevel.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/toplevel_after.yaml"
|
- debug: msg="START cli/toplevel_after.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -8,12 +8,14 @@
|
||||||
- "hostname {{ shorter_hostname }}"
|
- "hostname {{ shorter_hostname }}"
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- 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
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -27,6 +29,7 @@
|
||||||
lines: ['hostname foo']
|
lines: ['hostname foo']
|
||||||
after: ['snmp-server contact foo']
|
after: ['snmp-server contact foo']
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -40,5 +43,6 @@
|
||||||
- "hostname {{ shorter_hostname }}"
|
- "hostname {{ shorter_hostname }}"
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/toplevel_after.yaml"
|
- debug: msg="END cli/toplevel_after.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/toplevel_before.yaml"
|
- debug: msg="START cli/toplevel_before.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -8,12 +8,14 @@
|
||||||
- "hostname {{ shorter_hostname }}"
|
- "hostname {{ shorter_hostname }}"
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- 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
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -27,6 +29,7 @@
|
||||||
lines: ['hostname foo']
|
lines: ['hostname foo']
|
||||||
before: ['snmp-server contact foo']
|
before: ['snmp-server contact foo']
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -40,5 +43,6 @@
|
||||||
- "hostname {{ shorter_hostname }}"
|
- "hostname {{ shorter_hostname }}"
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/toplevel_before.yaml"
|
- debug: msg="END cli/toplevel_before.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,17 +1,19 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/toplevel_nonidempotent.yaml"
|
- debug: msg="START cli/toplevel_nonidempotent.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
lines: ['hostname {{ shorter_hostname }}']
|
lines: ['hostname {{ shorter_hostname }}']
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- 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
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -24,6 +26,7 @@
|
||||||
lines: ['hostname foo']
|
lines: ['hostname foo']
|
||||||
match: strict
|
match: strict
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -35,5 +38,6 @@
|
||||||
lines: ['hostname {{ shorter_hostname }}']
|
lines: ['hostname {{ shorter_hostname }}']
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/toplevel_nonidempotent.yaml"
|
- debug: msg="END cli/toplevel_nonidempotent.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -9,8 +9,14 @@
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/all_facts.yaml"
|
- debug: msg="START cli/all_facts.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
|
||||||
- name: test getting all facts
|
- name: test getting all facts
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
gather_subset:
|
gather_subset:
|
||||||
- all
|
- all
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
|
||||||
|
@ -28,4 +29,4 @@
|
||||||
- "result.ansible_facts.ansible_net_memfree_mb > 1"
|
- "result.ansible_facts.ansible_net_memfree_mb > 1"
|
||||||
- "result.ansible_facts.ansible_net_memtotal_mb > 1"
|
- "result.ansible_facts.ansible_net_memtotal_mb > 1"
|
||||||
|
|
||||||
- debug: msg="END cli/all_facts.yaml"
|
- debug: msg="END cli/all_facts.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/default_facts.yaml"
|
- debug: msg="START cli/default_facts.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
|
||||||
- name: test getting default facts
|
- name: test getting default facts
|
||||||
ios_facts:
|
ios_facts:
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -28,4 +29,4 @@
|
||||||
# ... and not present
|
# ... and not present
|
||||||
- "result.ansible_facts.ansible_net_config is not defined" # config
|
- "result.ansible_facts.ansible_net_config is not defined" # config
|
||||||
|
|
||||||
- debug: msg="END cli/default.yaml"
|
- debug: msg="END cli/default.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/invalid_subset.yaml"
|
- debug: msg="START cli/invalid_subset.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
|
||||||
- name: test invalid subset (foobar)
|
- name: test invalid subset (foobar)
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
gather_subset:
|
gather_subset:
|
||||||
- "foobar"
|
- "foobar"
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
- "!hardware"
|
- "!hardware"
|
||||||
- "hardware"
|
- "hardware"
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
|
|
||||||
|
@ -45,4 +47,4 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
- debug: msg="END cli/invalid_subset.yaml"
|
- debug: msg="END cli/invalid_subset.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/not_hardware_facts.yaml"
|
- debug: msg="START cli/not_hardware_facts.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
|
|
||||||
- name: test not hardware
|
- name: test not hardware
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
gather_subset:
|
gather_subset:
|
||||||
- "!hardware"
|
- "!hardware"
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -27,4 +28,4 @@
|
||||||
# ... and not present
|
# ... and not present
|
||||||
- "result.ansible_facts.ansible_net_filesystems is not defined"
|
- "result.ansible_facts.ansible_net_filesystems is not defined"
|
||||||
|
|
||||||
- debug: msg="END cli/not_hardware_facts.yaml"
|
- debug: msg="END cli/not_hardware_facts.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -4,12 +4,19 @@
|
||||||
paths: "{{ role_path }}/tests/cli"
|
paths: "{{ role_path }}/tests/cli"
|
||||||
patterns: "{{ testcase }}.yaml"
|
patterns: "{{ testcase }}.yaml"
|
||||||
register: test_cases
|
register: test_cases
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START ios_interface cli/basic.yaml"
|
- debug: msg="START ios_interface cli/basic.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: Run show version
|
- name: Run show version
|
||||||
ios_command:
|
ios_command:
|
||||||
commands: show version
|
commands: show version
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: show_version_result
|
register: show_version_result
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
- no negotiation auto
|
- no negotiation auto
|
||||||
parents: int GigabitEthernet2
|
parents: int GigabitEthernet2
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: Set test interface 2 to GigabitEthernet3 as we are on Cisco IOS-XE
|
- name: Set test interface 2 to GigabitEthernet3 as we are on Cisco IOS-XE
|
||||||
set_fact: test_interface2=GigabitEthernet3
|
set_fact: test_interface2=GigabitEthernet3
|
||||||
|
@ -32,6 +34,7 @@
|
||||||
- no negotiation auto
|
- no negotiation auto
|
||||||
parents: int GigabitEthernet3
|
parents: int GigabitEthernet3
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
when: "'Cisco IOS-XE' in show_version_result.stdout[0]"
|
when: "'Cisco IOS-XE' in show_version_result.stdout[0]"
|
||||||
|
|
||||||
- name: Configure interface (setup)
|
- name: Configure interface (setup)
|
||||||
|
@ -42,6 +45,7 @@
|
||||||
mtu: 1800
|
mtu: 1800
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Configure interface
|
- name: Configure interface
|
||||||
|
@ -50,6 +54,7 @@
|
||||||
description: test-interface-initial
|
description: test-interface-initial
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -64,6 +69,7 @@
|
||||||
description: test-interface-initial
|
description: test-interface-initial
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -77,6 +83,7 @@
|
||||||
mtu: 2000
|
mtu: 2000
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -93,6 +100,7 @@
|
||||||
mtu: 1800
|
mtu: 1800
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -107,6 +115,7 @@
|
||||||
name: "{{ test_interface }}"
|
name: "{{ test_interface }}"
|
||||||
enabled: False
|
enabled: False
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -120,6 +129,7 @@
|
||||||
name: "{{ test_interface }}"
|
name: "{{ test_interface }}"
|
||||||
enabled: True
|
enabled: True
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -136,6 +146,7 @@
|
||||||
mtu: 1800
|
mtu: 1800
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: Add interface aggregate
|
- name: Add interface aggregate
|
||||||
|
@ -146,6 +157,7 @@
|
||||||
speed: 1000
|
speed: 1000
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -165,6 +177,7 @@
|
||||||
speed: 1000
|
speed: 1000
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -179,6 +192,7 @@
|
||||||
enabled: False
|
enabled: False
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -197,6 +211,7 @@
|
||||||
enabled: True
|
enabled: True
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -214,6 +229,7 @@
|
||||||
- name: Loopback10
|
- name: Loopback10
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: Create loopback interface aggregate
|
- name: Create loopback interface aggregate
|
||||||
ios_interface:
|
ios_interface:
|
||||||
|
@ -222,6 +238,7 @@
|
||||||
- name: Loopback10
|
- name: Loopback10
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -237,6 +254,7 @@
|
||||||
- name: Loopback10
|
- name: Loopback10
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -252,10 +270,11 @@
|
||||||
- name: Loopback10
|
- name: Loopback10
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
that:
|
that:
|
||||||
- 'result.changed == false'
|
- 'result.changed == false'
|
||||||
|
|
||||||
- debug: msg="END ios_interface cli/basic.yaml"
|
- debug: msg="END ios_interface cli/basic.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START ios_interface cli/intent.yaml"
|
- debug: msg="START ios_interface cli/intent.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: Run show version
|
- name: Run show version
|
||||||
ios_command:
|
ios_command:
|
||||||
commands: show version
|
commands: show version
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: show_version_result
|
register: show_version_result
|
||||||
|
|
||||||
- name: Set test interface to GigabitEthernet0/2 if we are on Cisco IOS
|
- name: Set test interface to GigabitEthernet0/2 if we are on Cisco IOS
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
tx_rate: ge(0)
|
tx_rate: ge(0)
|
||||||
rx_rate: ge(0)
|
rx_rate: ge(0)
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -36,6 +38,7 @@
|
||||||
tx_rate: gt(0)
|
tx_rate: gt(0)
|
||||||
rx_rate: lt(0)
|
rx_rate: lt(0)
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -52,6 +55,7 @@
|
||||||
enabled: False
|
enabled: False
|
||||||
state: down
|
state: down
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -64,6 +68,7 @@
|
||||||
enabled: False
|
enabled: False
|
||||||
authorize: yes
|
authorize: yes
|
||||||
state: up
|
state: up
|
||||||
|
become: yes
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -77,6 +82,7 @@
|
||||||
commands:
|
commands:
|
||||||
- show lldp neighbors
|
- show lldp neighbors
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: show_lldp_neighbors_result
|
register: show_lldp_neighbors_result
|
||||||
|
|
||||||
- block:
|
- block:
|
||||||
|
@ -87,6 +93,7 @@
|
||||||
- port: eth0
|
- port: eth0
|
||||||
host: netdev
|
host: netdev
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -100,6 +107,7 @@
|
||||||
- port: dummy_port
|
- port: dummy_port
|
||||||
host: dummy_host
|
host: dummy_host
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -117,6 +125,7 @@
|
||||||
enabled: True
|
enabled: True
|
||||||
state: up
|
state: up
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -133,6 +142,7 @@
|
||||||
- port: eth0
|
- port: eth0
|
||||||
host: netdev
|
host: netdev
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
@ -150,6 +160,7 @@
|
||||||
- port: dummy_port
|
- port: dummy_port
|
||||||
host: dummy_host
|
host: dummy_host
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
ignore_errors: yes
|
ignore_errors: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
|
|
|
@ -4,12 +4,19 @@
|
||||||
paths: "{{ role_path }}/tests/cli"
|
paths: "{{ role_path }}/tests/cli"
|
||||||
patterns: "{{ testcase }}.yaml"
|
patterns: "{{ testcase }}.yaml"
|
||||||
register: test_cases
|
register: test_cases
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
name: 172.16.0.1
|
name: 172.16.0.1
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: Remove console
|
- name: Remove console
|
||||||
ios_logging:
|
ios_logging:
|
||||||
|
@ -13,6 +14,7 @@
|
||||||
level: warnings
|
level: warnings
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: Remove buffer
|
- name: Remove buffer
|
||||||
ios_logging:
|
ios_logging:
|
||||||
|
@ -20,6 +22,7 @@
|
||||||
size: 8000
|
size: 8000
|
||||||
authorize: yes
|
authorize: yes
|
||||||
state: absent
|
state: absent
|
||||||
|
become: yes
|
||||||
|
|
||||||
# start tests
|
# start tests
|
||||||
- name: Set up host logging
|
- name: Set up host logging
|
||||||
|
@ -29,6 +32,7 @@
|
||||||
facility: local7
|
facility: local7
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -43,6 +47,7 @@
|
||||||
name: 172.16.0.1
|
name: 172.16.0.1
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -55,6 +60,7 @@
|
||||||
name: 172.16.0.1
|
name: 172.16.0.1
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -68,6 +74,7 @@
|
||||||
name: 172.16.0.1
|
name: 172.16.0.1
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -80,6 +87,7 @@
|
||||||
level: warnings
|
level: warnings
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -92,6 +100,7 @@
|
||||||
dest: buffered
|
dest: buffered
|
||||||
size: 8000
|
size: 8000
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -105,6 +114,7 @@
|
||||||
- { dest: console, level: notifications }
|
- { dest: console, level: notifications }
|
||||||
- { dest: buffered, size: 9000 }
|
- { dest: buffered, size: 9000 }
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -120,6 +130,7 @@
|
||||||
- { dest: buffered, size: 9000 }
|
- { dest: buffered, size: 9000 }
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
|
|
@ -9,8 +9,14 @@
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/ping.yaml"
|
- debug: msg="START cli/ping.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- ios_command:
|
- ios_command:
|
||||||
commands: show version
|
commands: show version
|
||||||
|
|
|
@ -4,12 +4,19 @@
|
||||||
paths: "{{ role_path }}/tests/cli"
|
paths: "{{ role_path }}/tests/cli"
|
||||||
patterns: "{{ testcase }}.yaml"
|
patterns: "{{ testcase }}.yaml"
|
||||||
register: test_cases
|
register: test_cases
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
next_hop: 10.0.0.8
|
next_hop: 10.0.0.8
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -20,6 +21,7 @@
|
||||||
next_hop: 10.0.0.8
|
next_hop: 10.0.0.8
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -34,6 +36,7 @@
|
||||||
admin_distance: 2
|
admin_distance: 2
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -49,6 +52,7 @@
|
||||||
admin_distance: 2
|
admin_distance: 2
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -63,6 +67,7 @@
|
||||||
admin_distance: 2
|
admin_distance: 2
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -78,6 +83,7 @@
|
||||||
admin_distance: 2
|
admin_distance: 2
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -91,6 +97,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 }
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -106,6 +113,7 @@
|
||||||
- { 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
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -121,6 +129,7 @@
|
||||||
- { 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
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
|
|
@ -9,8 +9,14 @@
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/set_domain_search.yaml"
|
- debug: msg="START cli/set_domain_search.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
- no ip domain-list redhat.com
|
- no ip domain-list redhat.com
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure domain_search
|
- name: configure domain_search
|
||||||
ios_system:
|
ios_system:
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
- ansible.com
|
- ansible.com
|
||||||
- redhat.com
|
- redhat.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -29,6 +31,7 @@
|
||||||
- ansible.com
|
- ansible.com
|
||||||
- redhat.com
|
- redhat.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -40,6 +43,7 @@
|
||||||
domain_search:
|
domain_search:
|
||||||
- ansible.com
|
- ansible.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -52,6 +56,7 @@
|
||||||
domain_search:
|
domain_search:
|
||||||
- ansible.com
|
- ansible.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -64,6 +69,7 @@
|
||||||
- ansible.com
|
- ansible.com
|
||||||
- redhat.com
|
- redhat.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -77,6 +83,7 @@
|
||||||
- ansible.com
|
- ansible.com
|
||||||
- redhat.com
|
- redhat.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -89,6 +96,7 @@
|
||||||
- ansible.com
|
- ansible.com
|
||||||
- eng.ansible.com
|
- eng.ansible.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -104,6 +112,7 @@
|
||||||
- ansible.com
|
- ansible.com
|
||||||
- eng.ansible.com
|
- eng.ansible.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -118,5 +127,6 @@
|
||||||
- no ip domain-list eng.ansible.com
|
- no ip domain-list eng.ansible.com
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/set_domain_search.yaml"
|
- debug: msg="END cli/set_domain_search.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/set_domain_name.yaml"
|
- debug: msg="START cli/set_domain_name.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
lines: no ip domain-name
|
lines: no ip domain-name
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure domain_name
|
- name: configure domain_name
|
||||||
ios_system:
|
ios_system:
|
||||||
domain_name: eng.ansible.com
|
domain_name: eng.ansible.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -21,6 +23,7 @@
|
||||||
ios_system:
|
ios_system:
|
||||||
domain_name: eng.ansible.com
|
domain_name: eng.ansible.com
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -32,5 +35,6 @@
|
||||||
lines: no ip domain-name
|
lines: no ip domain-name
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/set_domain_name.yaml"
|
- debug: msg="END cli/set_domain_name.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,16 +1,18 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/set_hostname.yaml"
|
- debug: msg="START cli/set_hostname.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
lines: hostname switch
|
lines: hostname switch
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure hostname
|
- name: configure hostname
|
||||||
ios_system:
|
ios_system:
|
||||||
hostname: foo
|
hostname: foo
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -21,6 +23,7 @@
|
||||||
ios_system:
|
ios_system:
|
||||||
hostname: foo
|
hostname: foo
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -32,5 +35,6 @@
|
||||||
lines: "hostname {{ inventory_hostname }}"
|
lines: "hostname {{ inventory_hostname }}"
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/set_hostname.yaml"
|
- debug: msg="END cli/set_hostname.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/set_lookup_source.yaml"
|
- debug: msg="START cli/set_lookup_source.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -8,11 +8,13 @@
|
||||||
- vrf definition ansible
|
- vrf definition ansible
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure lookup_source
|
- name: configure lookup_source
|
||||||
ios_system:
|
ios_system:
|
||||||
lookup_source: Loopback888
|
lookup_source: Loopback888
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -24,6 +26,7 @@
|
||||||
ios_system:
|
ios_system:
|
||||||
lookup_source: Loopback888
|
lookup_source: Loopback888
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -34,6 +37,7 @@
|
||||||
ios_system:
|
ios_system:
|
||||||
lookup_enabled: False
|
lookup_enabled: False
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -45,6 +49,7 @@
|
||||||
ios_system:
|
ios_system:
|
||||||
lookup_enabled: True
|
lookup_enabled: True
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -59,6 +64,7 @@
|
||||||
# vrf: ansible
|
# vrf: ansible
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
# provider: "{{ cli }}"
|
# provider: "{{ cli }}"
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
#
|
#
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -75,6 +81,7 @@
|
||||||
# vrf: ansible
|
# vrf: ansible
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
# provider: "{{ cli }}"
|
# provider: "{{ cli }}"
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
#
|
#
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -88,7 +95,8 @@
|
||||||
- no vrf definition ansible
|
- no vrf definition ansible
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
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
|
||||||
|
|
||||||
- debug: msg="END cli/set_lookup_source.yaml"
|
- debug: msg="END cli/set_lookup_source.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- debug: msg="START cli/set_name_servers.yaml"
|
- debug: msg="START cli/set_name_servers.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
||||||
- name: setup
|
- name: setup
|
||||||
ios_config:
|
ios_config:
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
- no ip name-server
|
- no ip name-server
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: configure name_servers
|
- name: configure name_servers
|
||||||
ios_system:
|
ios_system:
|
||||||
|
@ -15,6 +16,7 @@
|
||||||
- 2.2.2.2
|
- 2.2.2.2
|
||||||
- 3.3.3.3
|
- 3.3.3.3
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -32,6 +34,7 @@
|
||||||
- 2.2.2.2
|
- 2.2.2.2
|
||||||
- 3.3.3.3
|
- 3.3.3.3
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -73,6 +76,7 @@
|
||||||
- 1.1.1.1
|
- 1.1.1.1
|
||||||
- 2.2.2.2
|
- 2.2.2.2
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -87,5 +91,6 @@
|
||||||
- no ip name-server
|
- no ip name-server
|
||||||
match: none
|
match: none
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
|
|
||||||
- debug: msg="END cli/set_name_servers.yaml"
|
- debug: msg="END cli/set_name_servers.yaml on connection={{ ansible_connection }}"
|
||||||
|
|
|
@ -4,12 +4,19 @@
|
||||||
paths: "{{ role_path }}/tests/cli"
|
paths: "{{ role_path }}/tests/cli"
|
||||||
patterns: "{{ testcase }}.yaml"
|
patterns: "{{ testcase }}.yaml"
|
||||||
register: test_cases
|
register: test_cases
|
||||||
|
delegate_to: localhost
|
||||||
|
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
configured_password: pass123
|
configured_password: pass123
|
||||||
|
become: yes
|
||||||
|
|
||||||
- name: test login
|
- name: test login
|
||||||
expect:
|
expect:
|
||||||
|
@ -34,6 +35,7 @@
|
||||||
name: auth_user
|
name: auth_user
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- name: reset connection
|
- name: reset connection
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
- name: ansibletest3
|
- name: ansibletest3
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
register: result
|
become: yes
|
||||||
|
|
||||||
- name: Create user (SetUp)
|
- name: Create user (SetUp)
|
||||||
ios_user:
|
ios_user:
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
role: network-operator
|
role: network-operator
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -31,6 +32,7 @@
|
||||||
authorize: yes
|
authorize: yes
|
||||||
state: present
|
state: present
|
||||||
view: network-admin
|
view: network-admin
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -45,6 +47,7 @@
|
||||||
role: network-operator
|
role: network-operator
|
||||||
state: present
|
state: present
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -60,6 +63,7 @@
|
||||||
authorize: yes
|
authorize: yes
|
||||||
state: present
|
state: present
|
||||||
view: network-admin
|
view: network-admin
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
@ -75,6 +79,7 @@
|
||||||
- name: ansibletest3
|
- name: ansibletest3
|
||||||
state: absent
|
state: absent
|
||||||
authorize: yes
|
authorize: yes
|
||||||
|
become: yes
|
||||||
register: result
|
register: result
|
||||||
|
|
||||||
- assert:
|
- assert:
|
||||||
|
|
|
@ -9,8 +9,14 @@
|
||||||
- name: set test_items
|
- 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
|
- name: run test cases (connection=network_cli)
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }} ansible_connection=network_cli"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: run test case (connection=local)
|
||||||
|
include: "{{ test_case_to_run }} ansible_connection=local ansible_become=no"
|
||||||
|
with_first_found: "{{ test_items }}"
|
||||||
|
loop_control:
|
||||||
|
loop_var: test_case_to_run
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
# - no vlan 200
|
# - no vlan 200
|
||||||
# - no vlan 300
|
# - no vlan 300
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
|
# become: yes
|
||||||
|
|
||||||
#- name: setup - remove switchport settings on interfaces used in test
|
#- name: setup - remove switchport settings on interfaces used in test
|
||||||
# ios_config:
|
# ios_config:
|
||||||
|
@ -14,6 +15,7 @@
|
||||||
# - no switchport access vlan 100
|
# - no switchport access vlan 100
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
# parents: "{{ item }}"
|
# parents: "{{ item }}"
|
||||||
|
# become: yes
|
||||||
# with_items:
|
# with_items:
|
||||||
# - interface GigabitEthernet0/1
|
# - interface GigabitEthernet0/1
|
||||||
# - interface GigabitEthernet0/2
|
# - interface GigabitEthernet0/2
|
||||||
|
@ -23,6 +25,7 @@
|
||||||
# vlan_id: 100
|
# vlan_id: 100
|
||||||
# name: test-vlan
|
# name: test-vlan
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -33,6 +36,7 @@
|
||||||
|
|
||||||
#- name: create vlan(idempotence)
|
#- name: create vlan(idempotence)
|
||||||
# ios_vlan: *create
|
# ios_vlan: *create
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -46,6 +50,7 @@
|
||||||
# - GigabitEthernet0/1
|
# - GigabitEthernet0/1
|
||||||
# - GigabitEthernet0/2
|
# - GigabitEthernet0/2
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -60,6 +65,7 @@
|
||||||
|
|
||||||
#- name: Add interfaces to vlan(idempotence)
|
#- name: Add interfaces to vlan(idempotence)
|
||||||
# ios_vlan: *interfaces
|
# ios_vlan: *interfaces
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -72,6 +78,7 @@
|
||||||
# interfaces:
|
# interfaces:
|
||||||
# - GigabitEthernet0/1
|
# - GigabitEthernet0/1
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -84,6 +91,7 @@
|
||||||
|
|
||||||
#- name: Remove interface from vlan(idempotence)
|
#- name: Remove interface from vlan(idempotence)
|
||||||
# ios_vlan: *single_int
|
# ios_vlan: *single_int
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -95,6 +103,7 @@
|
||||||
# vlan_id: 100
|
# vlan_id: 100
|
||||||
# state: suspend
|
# state: suspend
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -108,6 +117,7 @@
|
||||||
# vlan_id: 100
|
# vlan_id: 100
|
||||||
# state: active
|
# state: active
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -121,6 +131,7 @@
|
||||||
# vlan_id: 100
|
# vlan_id: 100
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
# state: absent
|
# state: absent
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -130,6 +141,7 @@
|
||||||
|
|
||||||
#- name: delete vlan(idempotence)
|
#- name: delete vlan(idempotence)
|
||||||
# ios_vlan: *delete
|
# ios_vlan: *delete
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -142,6 +154,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 }
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -154,6 +167,7 @@
|
||||||
|
|
||||||
#- name: create vlans using aggregate(idempotence)
|
#- name: create vlans using aggregate(idempotence)
|
||||||
# ios_vlan: *create_aggregate
|
# ios_vlan: *create_aggregate
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -167,6 +181,7 @@
|
||||||
# - { vlan_id: 300, name: vlan-300 }
|
# - { vlan_id: 300, name: vlan-300 }
|
||||||
# state: absent
|
# state: absent
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -177,6 +192,7 @@
|
||||||
|
|
||||||
#- name: delete vlans using aggregate(idempotence)
|
#- name: delete vlans using aggregate(idempotence)
|
||||||
# ios_vlan: *delete_aggregate
|
# ios_vlan: *delete_aggregate
|
||||||
|
# become: yes
|
||||||
# register: result
|
# register: result
|
||||||
|
|
||||||
#- assert:
|
#- assert:
|
||||||
|
@ -190,6 +206,7 @@
|
||||||
# - no vlan 200
|
# - no vlan 200
|
||||||
# - no vlan 300
|
# - no vlan 300
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
|
# become: yes
|
||||||
|
|
||||||
#- name: teardown(part2)
|
#- name: teardown(part2)
|
||||||
# ios_config:
|
# ios_config:
|
||||||
|
@ -198,6 +215,7 @@
|
||||||
# - no switchport access vlan 100
|
# - no switchport access vlan 100
|
||||||
# authorize: yes
|
# authorize: yes
|
||||||
# parents: "{{ item }}"
|
# parents: "{{ item }}"
|
||||||
|
# become: yes
|
||||||
# with_items:
|
# with_items:
|
||||||
# - interface GigabitEthernet0/1
|
# - interface GigabitEthernet0/1
|
||||||
# - interface GigabitEthernet0/2
|
# - interface GigabitEthernet0/2
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
- name: Ensure we have loopback 888 for testing
|
- name: Ensure we have loopback 888 for testing
|
||||||
ios_config:
|
ios_config:
|
||||||
src: config.j2
|
src: config.j2
|
||||||
authorize: yes
|
connection: network_cli
|
||||||
|
become: yes
|
||||||
|
|
||||||
# Some AWS hostnames can be longer than those allowed by the system we are testing
|
# Some AWS hostnames can be longer than those allowed by the system we are testing
|
||||||
# Truncate the hostname
|
# Truncate the hostname
|
||||||
|
|
|
@ -58,7 +58,7 @@ class TestIosUserModule(TestIosModule):
|
||||||
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 = json.loads(
|
||||||
'{"answer": "y", ' +
|
'{"answer": "y", "newline": false, ' +
|
||||||
'"prompt": "This operation will remove all username related ' +
|
'"prompt": "This operation will remove all username related ' +
|
||||||
'configurations with same name", "command": "no username ansible"}'
|
'configurations with same name", "command": "no username ansible"}'
|
||||||
)
|
)
|
||||||
|
@ -87,7 +87,7 @@ class TestIosUserModule(TestIosModule):
|
||||||
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 = json.loads(
|
||||||
'{"answer": "y", ' +
|
'{"answer": "y", "newline": false, ' +
|
||||||
'"prompt": "This operation will remove all username related ' +
|
'"prompt": "This operation will remove all username related ' +
|
||||||
'configurations with same name", "command": "no username ansible"}'
|
'configurations with same name", "command": "no username ansible"}'
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue