IOS XR cli tests move to network_cli (#34007)

* Update task definitions for network_cli

* Add connection to debug messages

* Specify connection for prepare task

* pc won't be around for connection=network_cli

* Assorted Python 3 fixes

* Give default port if ansible_ssh_port missing

* delegate -> connection

* Extend error regex
pull/32207/merge
Nathaniel Case 7 years ago committed by GitHub
parent 5db9ac23ee
commit 2e76c89910
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -374,7 +374,7 @@ def get_config(module, config_filter=None, source='running'):
if is_netconf(module): if is_netconf(module):
out = to_xml(conn.get_config(source=source, filter=config_filter)) out = to_xml(conn.get_config(source=source, filter=config_filter))
cfg = to_bytes(out, errors='surrogate_then_replace').strip() cfg = out.strip()
_DEVICE_CONFIGS.update({key: cfg}) _DEVICE_CONFIGS.update({key: cfg})
return cfg return cfg

@ -328,7 +328,7 @@ def convert_key_to_base64(module):
splitfile = key.split()[1] splitfile = key.split()[1]
base64key = b64decode(splitfile) base64key = b64decode(splitfile)
base64file = open('/tmp/publickey_%s.b64' % (name), 'w') base64file = open('/tmp/publickey_%s.b64' % (name), 'bw')
base64file.write(base64key) base64file.write(base64key)
base64file.close() base64file.close()

@ -80,7 +80,7 @@ class ActionModule(_ActionModule):
# make sure we are in the right cli context which should be # make sure we are in the right cli context which should be
# enable mode and not config module # enable mode and not config module
if pc.connection == 'network_cli': if (self._play_context.connection == 'local' and pc.connection == 'network_cli') or self._play_context.connection == 'network_cli':
if socket_path is None: if socket_path is None:
socket_path = self._connection.socket_path socket_path = self._connection.socket_path

@ -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]
@ -74,7 +74,7 @@ class ActionModule(_ActionModule):
os.remove(fn) os.remove(fn)
tstamp = time.strftime("%Y-%m-%d@%H:%M:%S", time.localtime(time.time())) tstamp = time.strftime("%Y-%m-%d@%H:%M:%S", time.localtime(time.time()))
filename = '%s/%s_config.%s' % (backup_path, host, tstamp) filename = '%s/%s_config.%s' % (backup_path, host, tstamp)
open(filename, 'w').write(to_bytes(contents)) open(filename, 'w').write(contents)
return filename return filename
def _handle_template(self): def _handle_template(self):

@ -61,9 +61,9 @@ class Cliconf(CliconfBase):
if source not in lookup: if source not in lookup:
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 filter: if filter:
cmd = to_bytes(b'show {0} {1}'.format(lookup[source], filter), errors='surrogate_or_strict') cmd = to_bytes('show {0} {1}'.format(lookup[source], filter), errors='surrogate_or_strict')
else: else:
cmd = to_bytes(b'show {0}'.format(lookup[source]), errors='surrogate_or_strict') cmd = to_bytes('show {0}'.format(lookup[source]), errors='surrogate_or_strict')
return self.send_command(cmd) return self.send_command(cmd)
@ -76,10 +76,10 @@ class Cliconf(CliconfBase):
def commit(self, comment=None): def commit(self, comment=None):
if comment: if comment:
command = b'commit comment {0}'.format(comment) command = 'commit comment {0}'.format(comment)
else: else:
command = b'commit' command = 'commit'
self.send_command(command) self.send_command(to_bytes(command))
def discard_changes(self): def discard_changes(self):
self.send_command(b'abort') self.send_command(b'abort')

@ -37,6 +37,7 @@ class TerminalModule(TerminalBase):
terminal_stderr_re = [ terminal_stderr_re = [
re.compile(br"% ?Error"), re.compile(br"% ?Error"),
re.compile(br"% ?Bad secret"), re.compile(br"% ?Bad secret"),
re.compile(br"% ?This command is not authorized"),
re.compile(br"invalid input", re.I), re.compile(br"invalid input", re.I),
re.compile(br"(?:incomplete|ambiguous) command", re.I), re.compile(br"(?:incomplete|ambiguous) command", re.I),
re.compile(br"connection timed out", re.I), re.compile(br"connection timed out", re.I),

@ -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 case (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"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

@ -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 case (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"
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
iosxr_command: iosxr_command:
@ -16,4 +16,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
iosxr_command: iosxr_command:
@ -16,4 +16,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,5 +1,5 @@
--- ---
- debug: msg="START cli/invalid.yaml" - debug: msg="START cli/invalid.yaml on connection={{ ansible_connection }}"
- name: run invalid command - name: run invalid command
iosxr_command: iosxr_command:
@ -23,4 +23,4 @@
that: that:
- "result.failed" - "result.failed"
- debug: msg="END cli/invalid.yaml" - debug: msg="END cli/invalid.yaml on connection={{ ansible_connection }}"

@ -1,5 +1,5 @@
--- ---
- 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
iosxr_command: iosxr_command:
@ -24,4 +24,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
iosxr_command: iosxr_command:
@ -15,4 +15,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 case (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"
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
iosxr_config: iosxr_config:
@ -14,8 +14,8 @@
find: find:
paths: "{{ role_path }}/backup" paths: "{{ role_path }}/backup"
pattern: "{{ inventory_hostname_short }}_config*" pattern: "{{ inventory_hostname_short }}_config*"
connection: local
register: backup_files register: backup_files
delegate_to: localhost
- name: delete backup files - name: delete backup files
file: file:
@ -38,11 +38,11 @@
find: find:
paths: "{{ role_path }}/backup" paths: "{{ role_path }}/backup"
pattern: "{{ inventory_hostname_short }}_config*" pattern: "{{ inventory_hostname_short }}_config*"
connection: local
register: backup_files register: backup_files
delegate_to: localhost
- 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/comment-too-long.yaml" - debug: msg="START cli/comment-too-long.yaml on connection={{ ansible_connection }}"
- name: setup - name: setup
iosxr_config: iosxr_config:
@ -27,4 +27,4 @@
# Check for the correct error message (and not a generic "Invalid input detected") once fixed # Check for the correct error message (and not a generic "Invalid input detected") once fixed
- debug: msg="END cli/comment-too-long.yaml" - debug: msg="END cli/comment-too-long.yaml on connection={{ ansible_connection }}"

@ -1,5 +1,5 @@
--- ---
- debug: msg="START cli/comment.yaml" - debug: msg="START cli/comment.yaml on connection={{ ansible_connection }}"
- name: setup - name: setup
iosxr_config: iosxr_config:
@ -31,4 +31,4 @@
- "result.changed == false" - "result.changed == false"
- "result.updates is not defined" - "result.updates is not defined"
- debug: msg="END cli/comment.yaml" - debug: msg="END cli/comment.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
iosxr_config: iosxr_config:
@ -32,4 +32,4 @@
# https://github.com/ansible/ansible-modules-core/issues/4807 # https://github.com/ansible/ansible-modules-core/issues/4807
- "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
@ -15,4 +15,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
iosxr_config: iosxr_config:
@ -34,4 +34,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 - name: setup
iosxr_config: iosxr_config:
@ -34,4 +34,4 @@
commands: ['no ipv4 access-list test'] commands: ['no ipv4 access-list test']
match: none match: none
- 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
iosxr_config: iosxr_config:
@ -9,7 +9,6 @@
- 30 permit ipv4 host 3.3.3.3 any log - 30 permit ipv4 host 3.3.3.3 any log
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
before: ['no ipv4 access-list test'] before: ['no ipv4 access-list test']
after: ['exit']
match: none match: none
- name: configure sub level command using block resplace - name: configure sub level command using block resplace
@ -21,7 +20,6 @@
- 40 permit ipv4 host 4.4.4.4 any log - 40 permit ipv4 host 4.4.4.4 any log
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
replace: block replace: block
after: ['exit']
register: result register: result
- assert: - assert:
@ -42,7 +40,6 @@
- 40 permit ipv4 host 4.4.4.4 any log - 40 permit ipv4 host 4.4.4.4 any log
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
replace: block replace: block
after: ['exit']
register: result register: result
- assert: - assert:
@ -54,4 +51,4 @@
commands: ['no ipv4 access-list test'] commands: ['no ipv4 access-list test']
match: none match: none
- 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
iosxr_config: iosxr_config:
@ -11,7 +11,6 @@
- 50 permit ipv4 host 5.5.5.5 any log - 50 permit ipv4 host 5.5.5.5 any log
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
before: ['no ipv4 access-list test'] before: ['no ipv4 access-list test']
after: ['exit']
match: none match: none
- name: configure sub level command using exact match - name: configure sub level command using exact match
@ -22,7 +21,6 @@
- 30 permit ipv4 host 3.3.3.3 any log - 30 permit ipv4 host 3.3.3.3 any log
- 40 permit ipv4 host 4.4.4.4 any log - 40 permit ipv4 host 4.4.4.4 any log
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
after: ['exit']
match: exact match: exact
register: result register: result
@ -45,7 +43,6 @@
- 40 permit ipv4 host 4.4.4.4 any log - 40 permit ipv4 host 4.4.4.4 any log
- 50 permit ipv4 host 5.5.5.5 any log - 50 permit ipv4 host 5.5.5.5 any log
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
after: ['exit']
match: exact match: exact
register: result register: result
@ -58,4 +55,4 @@
commands: ['no ipv4 access-list test'] commands: ['no ipv4 access-list test']
match: none match: none
- 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
iosxr_config: iosxr_config:
@ -11,7 +11,6 @@
- 50 permit ipv4 host 5.5.5.5 any log - 50 permit ipv4 host 5.5.5.5 any log
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
before: ['no ipv4 access-list test'] before: ['no ipv4 access-list test']
after: ['exit']
match: none match: none
- name: configure sub level command using strict match - name: configure sub level command using strict match
@ -23,7 +22,6 @@
- 40 permit ipv4 host 4.4.4.4 any log - 40 permit ipv4 host 4.4.4.4 any log
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
before: ['no ipv4 access-list test'] before: ['no ipv4 access-list test']
after: ['exit']
match: strict match: strict
replace: block replace: block
register: result register: result
@ -46,7 +44,6 @@
- 30 permit ipv4 host 3.3.3.3 any log - 30 permit ipv4 host 3.3.3.3 any log
- 40 permit ipv4 host 4.4.4.4 any log - 40 permit ipv4 host 4.4.4.4 any log
parents: ['ipv4 access-list test'] parents: ['ipv4 access-list test']
after: ['exit']
match: strict match: strict
register: result register: result
@ -59,4 +56,4 @@
commands: ['no ipv4 access-list test'] commands: ['no ipv4 access-list test']
match: none match: none
- debug: msg="END cli/sublevel_strict.yaml" - debug: msg="END cli/sublevel_strict.yaml on connection={{ ansible_connection }}"

@ -1,5 +1,5 @@
--- ---
- debug: msg="START cli/toplevel.yaml" - debug: msg="START cli/toplevel.yaml on connection={{ ansible_connection }}"
- name: setup - name: setup
iosxr_config: iosxr_config:
@ -30,4 +30,4 @@
commands: ['hostname {{ inventory_hostname_short }}'] commands: ['hostname {{ inventory_hostname_short }}']
match: none match: none
- 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
iosxr_config: iosxr_config:
@ -37,4 +37,4 @@
- "hostname {{ inventory_hostname_short }}" - "hostname {{ inventory_hostname_short }}"
match: none match: none
- 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
iosxr_config: iosxr_config:
@ -37,4 +37,4 @@
- "hostname {{ inventory_hostname_short }}" - "hostname {{ inventory_hostname_short }}"
match: none match: none
- debug: msg="END cli/toplevel_before.yaml" - debug: msg="END cli/toplevel_before.yaml on connection={{ ansible_connection }}"

@ -1,5 +1,5 @@
--- ---
- debug: msg="START cli/toplevel_nonidempotent.yaml" - debug: msg="START cli/toplevel_nonidempotent.yaml on connection={{ ansible_connection }}"
- name: setup - name: setup
iosxr_config: iosxr_config:
@ -33,4 +33,4 @@
commands: ['hostname {{ inventory_hostname_short }}'] commands: ['hostname {{ inventory_hostname_short }}']
match: none match: none
- 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 case (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"
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
@ -25,4 +25,4 @@
# Items from those subsets are present # Items from those subsets are present
- "result.ansible_facts.ansible_net_filesystems is defined" - "result.ansible_facts.ansible_net_filesystems is defined"
- debug: msg="END cli/all_facts.yaml" - debug: msg="END cli/all_facts.yaml on connection={{ ansible_connection }}"

@ -1,5 +1,5 @@
--- ---
- 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
@ -27,4 +27,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)
@ -45,4 +45,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
@ -27,4 +27,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 }}"

@ -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 case (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"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

@ -1,5 +1,5 @@
--- ---
- debug: msg="START iosxr_interface cli/basic.yaml" - debug: msg="START iosxr_interface cli/basic.yaml on connection={{ ansible_connection }}"
- name: Setup interface - name: Setup interface
iosxr_interface: iosxr_interface:
@ -256,4 +256,4 @@
that: that:
- 'result.changed == false' - 'result.changed == false'
- debug: msg="END iosxr_interface cli/basic.yaml" - debug: msg="END iosxr_interface cli/basic.yaml on connection={{ ansible_connection }}"

@ -1,5 +1,5 @@
--- ---
- debug: msg="START iosxr_interface cli/intent.yaml" - debug: msg="START iosxr_interface cli/intent.yaml on connection={{ ansible_connection }}"
- name: Setup (interface is up) - name: Setup (interface is up)
iosxr_interface: iosxr_interface:

@ -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 case (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"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

@ -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 case (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"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

@ -1,5 +1,5 @@
--- ---
- debug: msg="START iosxr_netconf cli/basic.yaml" - debug: msg="START iosxr_netconf cli/basic.yaml on connection={{ ansible_connection }}"
- name: Disable NetConf service - name: Disable NetConf service
iosxr_netconf: &disable_netconf iosxr_netconf: &disable_netconf
@ -66,4 +66,4 @@
- name: Disable Netconf service - name: Disable Netconf service
iosxr_netconf: *disable_netconf iosxr_netconf: *disable_netconf
- debug: msg="END iosxr_netconf cli/basic.yaml" - debug: msg="END iosxr_netconf cli/basic.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 case (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"
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
iosxr_config: iosxr_config:
@ -119,4 +119,4 @@
match: none match: none
provider: "{{ cli }}" provider: "{{ cli }}"
- debug: msg="END cli/set_domain_search.yaml" - debug: msg="END cli/set_domain_search.yaml on connection={{ ansible_connection }}"

@ -1,5 +1,5 @@
--- ---
- debug: msg="START cli/set_domain_name.yaml" - debug: msg="START cli/set_domain_name.yaml on connection={{ ansible_connection }}"
- name: setup - name: setup
iosxr_config: iosxr_config:
@ -33,4 +33,4 @@
match: none match: none
provider: "{{ cli }}" provider: "{{ cli }}"
- debug: msg="END cli/set_domain_name.yaml" - debug: msg="END cli/set_domain_name.yaml on connection={{ ansible_connection }}"

@ -1,5 +1,5 @@
--- ---
- debug: msg="START cli/set_hostname.yaml" - debug: msg="START cli/set_hostname.yaml on connection={{ ansible_connection }}"
- name: setup - name: setup
iosxr_config: iosxr_config:
@ -33,4 +33,4 @@
match: none match: none
provider: "{{ cli }}" provider: "{{ cli }}"
- 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
iosxr_config: iosxr_config:
@ -63,4 +63,4 @@
match: none match: none
provider: "{{ cli }}" provider: "{{ cli }}"
- 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
iosxr_config: iosxr_config:
@ -83,4 +83,4 @@
# FIXME: No teardown # FIXME: No teardown
# #
- debug: msg="END cli/set_name_servers.yaml" - debug: msg="END cli/set_name_servers.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 case (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"
with_first_found: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

@ -9,13 +9,13 @@
- name: test login - name: test login
expect: expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version" command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version"
responses: responses:
(?i)password: "pass123" (?i)password: "pass123"
- name: test login with invalid password (should fail) - name: test login with invalid password (should fail)
expect: expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version" command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version"
responses: responses:
(?i)password: "badpass" (?i)password: "badpass"
ignore_errors: yes ignore_errors: yes
@ -35,7 +35,7 @@
- name: test login with private key - name: test login with private key
expect: expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version" command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version"
responses: responses:
(?i)password: 'pass123' (?i)password: 'pass123'
@ -47,7 +47,7 @@
- name: test login with private key (should fail, no user) - name: test login with private key (should fail, no user)
expect: expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version" command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version"
responses: responses:
(?i)password: 'pass123' (?i)password: 'pass123'
ignore_errors: yes ignore_errors: yes
@ -62,7 +62,7 @@
- name: test login with private key - name: test login with private key
expect: expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version" command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version"
responses: responses:
(?i)password: 'pass123' (?i)password: 'pass123'
ignore_errors: yes ignore_errors: yes
@ -77,7 +77,7 @@
# FIXME: pexpect fails with OSError: [Errno 5] Input/output error # FIXME: pexpect fails with OSError: [Errno 5] Input/output error
- name: test login with invalid private key (should fail) - name: test login with invalid private key (should fail)
expect: expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version" command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i {{ role_path }}/files/private show version"
responses: responses:
(?i)password: "pass123" (?i)password: "pass123"
ignore_errors: yes ignore_errors: yes

@ -3,6 +3,7 @@
- name: Ensure we have loopback 888 for testing - name: Ensure we have loopback 888 for testing
iosxr_config: iosxr_config:
src: config.j2 src: config.j2
connection: network_cli
# 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

Loading…
Cancel
Save