To backport ios_user and ios_command TC failure fix (#70253)

pull/70314/head
Sumit Jaiswal 4 years ago committed by GitHub
parent 3b7f71dfae
commit d672ee1c03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
---
bugfixes:
- To fix ios_user and ios_command test case failure fix (https://github.com/ansible-collections/cisco.ios/pull/82)

@ -11,11 +11,19 @@
- "\r"
ignore_errors: True
- name: increase log buffer size
cli_config:
config: logging buffered 9600000
- name: send log with error regex match 1
cli_command: &send_logs
command: "send log 'IPSEC-3-REPLAY_ERROR: test log_1'"
command: "send log 'IPSEC-3-REPLAY_ERROR: test log_1'\n"
ignore_errors: True
- name: pause to avoid rate limiting-1
pause:
seconds: 20
- name: fetch logs without command specific error regex
ios_command:
commands:
@ -28,9 +36,9 @@
that:
- "result.failed == true"
- name: pause to avoid rate limiting
- name: pause to avoid rate limiting-2
pause:
seconds: 10
seconds: 20
- name: clear logs 2
cli_command: *clear_logs

@ -14,9 +14,3 @@
with_items: "{{ test_items }}"
loop_control:
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

@ -6,22 +6,34 @@
privilege: 15
role: network-operator
state: present
provider: "{{ cli }}"
configured_password: pass123
- name: test login
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=no show version"
responses:
(?i)password: "pass123"
- name: reset connection with {{ ansible_user }
meta: reset_connection
- name: test login for {{ ansible_user }} user with password
ios_command:
commands:
- show version
vars:
ansible_user: auth_user
ansible_password: pass123
- name: reset connection with {{ ansible_user }
meta: reset_connection
- name: test login with invalid password (should fail)
expect:
command: "ssh auth_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=no show version"
responses:
(?i)password: "badpass"
ios_command:
commands:
- show version
ignore_errors: yes
register: results
vars:
ansible_user: auth_user
ansible_password: badpass
- name: reset connection with {{ ansible_user }
meta: reset_connection
- name: check that attempt failed
assert:
@ -33,7 +45,6 @@
ios_user:
name: auth_user
state: absent
provider: "{{ cli }}"
register: result
- name: reset connection
@ -52,19 +63,34 @@
privilege: 15
role: network-operator
state: present
provider: "{{ cli }}"
sshkey: "{{ lookup('file', 'files/test_rsa.pub') }}"
- name: test sshkey login
shell: "ssh ssh_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o IdentityFile={{ role_path }}/files/test_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o BatchMode=yes -o PubkeyAuthentication=yes show version"
- name: reset connection with {{ ansible_user }
meta: reset_connection
- name: test sshkey login for {{ ansible_user }} user
ios_command:
commands:
- show version
vars:
ansible_user: ssh_user
ansible_private_key_file: "{{ role_path }}/files/test_rsa"
- name: reset connection with {{ ansible_user }}
meta: reset_connection
- name: test login without sshkey (should fail)
expect:
command: "ssh ssh_user@{{ ansible_ssh_host }} -p {{ ansible_ssh_port|default(22) }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o PubkeyAuthentication=no show version"
responses:
(?i)password: badpass
- name: test with {{ ansible_user }} user without keys
ios_command:
commands:
- show version
ignore_errors: yes
register: results
vars:
ansible_user: ssh_user
ansible_private_key_file: ""
- name: reset connection with {{ ansible_user }}
meta: reset_connection
- name: check that attempt failed
assert:
@ -76,7 +102,6 @@
ios_user:
name: ssh_user
state: absent
provider: "{{ cli }}"
register: result
- name: reset connection

Loading…
Cancel
Save