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" - "\r"
ignore_errors: True ignore_errors: True
- name: increase log buffer size
cli_config:
config: logging buffered 9600000
- name: send log with error regex match 1 - name: send log with error regex match 1
cli_command: &send_logs 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 ignore_errors: True
- name: pause to avoid rate limiting-1
pause:
seconds: 20
- name: fetch logs without command specific error regex - name: fetch logs without command specific error regex
ios_command: ios_command:
commands: commands:
@ -28,9 +36,9 @@
that: that:
- "result.failed == true" - "result.failed == true"
- name: pause to avoid rate limiting - name: pause to avoid rate limiting-2
pause: pause:
seconds: 10 seconds: 20
- name: clear logs 2 - name: clear logs 2
cli_command: *clear_logs cli_command: *clear_logs

@ -14,9 +14,3 @@
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

@ -6,22 +6,34 @@
privilege: 15 privilege: 15
role: network-operator role: network-operator
state: present state: present
provider: "{{ cli }}"
configured_password: pass123 configured_password: pass123
- name: test login - name: reset connection with {{ ansible_user }
expect: meta: reset_connection
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: - name: test login for {{ ansible_user }} user with password
(?i)password: "pass123" 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) - name: test login with invalid password (should fail)
expect: ios_command:
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" commands:
responses: - show version
(?i)password: "badpass"
ignore_errors: yes ignore_errors: yes
register: results register: results
vars:
ansible_user: auth_user
ansible_password: badpass
- name: reset connection with {{ ansible_user }
meta: reset_connection
- name: check that attempt failed - name: check that attempt failed
assert: assert:
@ -33,7 +45,6 @@
ios_user: ios_user:
name: auth_user name: auth_user
state: absent state: absent
provider: "{{ cli }}"
register: result register: result
- name: reset connection - name: reset connection
@ -52,19 +63,34 @@
privilege: 15 privilege: 15
role: network-operator role: network-operator
state: present state: present
provider: "{{ cli }}"
sshkey: "{{ lookup('file', 'files/test_rsa.pub') }}" sshkey: "{{ lookup('file', 'files/test_rsa.pub') }}"
- name: test sshkey login - name: reset connection with {{ ansible_user }
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" 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) - name: test with {{ ansible_user }} user without keys
expect: ios_command:
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" commands:
responses: - show version
(?i)password: badpass
ignore_errors: yes ignore_errors: yes
register: results 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 - name: check that attempt failed
assert: assert:
@ -76,7 +102,6 @@
ios_user: ios_user:
name: ssh_user name: ssh_user
state: absent state: absent
provider: "{{ cli }}"
register: result register: result
- name: reset connection - name: reset connection

Loading…
Cancel
Save