2017-06-08 08:58:29 +02:00
|
|
|
---
|
2017-12-19 21:49:49 +01:00
|
|
|
- debug: msg="START cli/basic.yaml on connection={{ ansible_connection }}"
|
|
|
|
|
2017-08-16 08:38:59 +02:00
|
|
|
- name: Set Up
|
|
|
|
eos_config:
|
|
|
|
lines:
|
|
|
|
- no username ansibletest1
|
|
|
|
- no username ansibletest2
|
|
|
|
- no username ansibletest3
|
2017-10-26 09:10:58 +02:00
|
|
|
- no username ansibletest4
|
2017-08-16 08:38:59 +02:00
|
|
|
provider: "{{ cli }}"
|
2017-12-19 21:49:49 +01:00
|
|
|
become: yes
|
2017-08-16 08:38:59 +02:00
|
|
|
|
2017-10-26 09:10:58 +02:00
|
|
|
- name: Create user with role
|
2017-06-08 08:58:29 +02:00
|
|
|
eos_user:
|
2017-08-16 08:38:59 +02:00
|
|
|
name: ansibletest1
|
2017-06-08 08:58:29 +02:00
|
|
|
privilege: 15
|
|
|
|
role: network-operator
|
|
|
|
state: present
|
2017-08-31 21:29:57 +02:00
|
|
|
configured_password: test1
|
2017-06-08 08:58:29 +02:00
|
|
|
provider: "{{ cli }}"
|
2017-12-19 21:49:49 +01:00
|
|
|
become: yes
|
2017-06-08 08:58:29 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-08-31 21:29:57 +02:00
|
|
|
- '"username" in result.commands[0]'
|
2017-10-26 09:10:58 +02:00
|
|
|
- '"secret" in result.commands[0]'
|
|
|
|
- '"role network-operator" in result.commands[1]'
|
|
|
|
- '"privilege 15" in result.commands[2]'
|
|
|
|
|
|
|
|
- name: Create user with priv level and update_password
|
|
|
|
eos_user:
|
|
|
|
name: ansibletest4
|
|
|
|
privilege: 15
|
|
|
|
state: present
|
|
|
|
configured_password: test1
|
|
|
|
update_password: on_create
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 21:49:49 +01:00
|
|
|
become: yes
|
2017-10-26 09:10:58 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- '"username" in result.commands[0]'
|
|
|
|
- '"secret" in result.commands[0]'
|
2017-08-31 21:29:57 +02:00
|
|
|
- '"privilege 15" in result.commands[1]'
|
2017-06-08 08:58:29 +02:00
|
|
|
|
|
|
|
- name: Collection of users
|
|
|
|
eos_user:
|
2017-07-26 16:09:17 +02:00
|
|
|
aggregate:
|
2017-08-31 21:29:57 +02:00
|
|
|
- { name: ansibletest2, configured_password: test2 }
|
|
|
|
- { name: ansibletest3, configured_password: test3 }
|
2017-06-08 08:58:29 +02:00
|
|
|
state: present
|
2017-07-17 13:56:32 +02:00
|
|
|
role: network-operator
|
2017-06-08 08:58:29 +02:00
|
|
|
provider: "{{ cli }}"
|
2017-12-19 21:49:49 +01:00
|
|
|
become: yes
|
2017-06-08 08:58:29 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-08-31 21:29:57 +02:00
|
|
|
- '"username" in result.commands[0]'
|
2017-10-27 17:52:56 +02:00
|
|
|
- '"role network-operator" in result.commands[1]'
|
|
|
|
- '"secret" in result.commands[0]'
|
2017-08-31 21:29:57 +02:00
|
|
|
- '"username" in result.commands[2]'
|
2017-10-27 17:52:56 +02:00
|
|
|
- '"role network-operator" in result.commands[3]'
|
|
|
|
- '"secret" in result.commands[2]'
|
2017-08-31 21:29:57 +02:00
|
|
|
|
|
|
|
- name: Add user without password or nopassword arg(Should fail)
|
|
|
|
eos_user:
|
|
|
|
name: faileduser1
|
|
|
|
privilege: 15
|
|
|
|
state: present
|
|
|
|
provider: "{{ cli }}"
|
2017-12-19 21:49:49 +01:00
|
|
|
become: yes
|
2017-08-31 21:29:57 +02:00
|
|
|
ignore_errors: yes
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
- 'result.failed == true'
|
|
|
|
- 'result.msg == "configured_password, sshkey or nopassword should be provided"'
|
2017-06-08 08:58:29 +02:00
|
|
|
|
|
|
|
- name: tearDown
|
2017-07-17 14:28:03 +02:00
|
|
|
eos_config:
|
|
|
|
lines:
|
2017-08-16 08:38:59 +02:00
|
|
|
- no username ansibletest1
|
|
|
|
- no username ansibletest2
|
|
|
|
- no username ansibletest3
|
2017-10-26 09:10:58 +02:00
|
|
|
- no username ansibletest4
|
2017-06-08 08:58:29 +02:00
|
|
|
provider: "{{ cli }}"
|
2017-12-19 21:49:49 +01:00
|
|
|
become: yes
|