2017-08-25 17:25:15 +02:00
|
|
|
---
|
|
|
|
- block:
|
|
|
|
- name: Create user with password
|
|
|
|
eos_user:
|
|
|
|
name: auth_user
|
|
|
|
privilege: 15
|
|
|
|
role: network-operator
|
|
|
|
state: present
|
2019-10-15 21:53:51 +02:00
|
|
|
authorize: yes
|
2017-08-25 17:25:15 +02:00
|
|
|
provider: "{{ cli }}"
|
|
|
|
configured_password: pass123
|
2017-12-19 21:49:49 +01:00
|
|
|
become: yes
|
2017-08-25 17:25:15 +02:00
|
|
|
|
|
|
|
- name: test login
|
|
|
|
expect:
|
|
|
|
command: "ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version"
|
|
|
|
responses:
|
|
|
|
(?i)password: "pass123"
|
|
|
|
|
|
|
|
- name: test login with invalid password (should fail)
|
|
|
|
expect:
|
|
|
|
command: "ssh auth_user@{{ ansible_ssh_host }} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no show version"
|
|
|
|
responses:
|
|
|
|
(?i)password: "badpass"
|
|
|
|
ignore_errors: yes
|
|
|
|
register: results
|
|
|
|
|
|
|
|
- name: check that attempt failed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- results.failed
|
|
|
|
|
|
|
|
always:
|
|
|
|
- name: delete user
|
|
|
|
eos_user:
|
|
|
|
name: auth_user
|
|
|
|
state: absent
|
|
|
|
provider: "{{ cli }}"
|
2019-10-15 21:53:51 +02:00
|
|
|
authorize: yes
|
2017-12-19 21:49:49 +01:00
|
|
|
become: yes
|
2017-08-25 17:25:15 +02:00
|
|
|
register: result
|