2017-06-09 10:20:57 +02:00
|
|
|
---
|
2017-08-16 11:45:41 +02:00
|
|
|
- name: tear down old users if they exist (Setup)
|
2019-05-28 14:08:37 +02:00
|
|
|
become: true
|
2017-08-16 11:45:41 +02:00
|
|
|
ios_user:
|
|
|
|
aggregate:
|
|
|
|
- name: ansibletest1
|
|
|
|
- name: ansibletest2
|
|
|
|
- name: ansibletest3
|
2018-10-31 12:21:46 +01:00
|
|
|
- name: ansibletest4
|
|
|
|
- name: ansibletest5
|
2018-12-12 17:52:15 +01:00
|
|
|
- name: ansibletest6
|
2017-08-16 11:45:41 +02:00
|
|
|
state: absent
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-08-16 11:45:41 +02:00
|
|
|
|
2017-06-16 08:28:06 +02:00
|
|
|
- name: Create user (SetUp)
|
2019-05-28 14:08:37 +02:00
|
|
|
become: true
|
2017-06-09 10:20:57 +02:00
|
|
|
ios_user:
|
2017-06-16 08:28:06 +02:00
|
|
|
name: ansibletest1
|
2017-06-09 10:20:57 +02:00
|
|
|
privilege: 15
|
|
|
|
role: network-operator
|
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-09 10:20:57 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-06-16 08:28:06 +02:00
|
|
|
- 'result.commands == ["username ansibletest1 view network-operator", "username ansibletest1 privilege 15"]'
|
2017-06-09 10:20:57 +02:00
|
|
|
|
2017-06-16 08:28:06 +02:00
|
|
|
- name: Collection of users (SetUp)
|
2019-05-28 14:08:37 +02:00
|
|
|
become: true
|
2017-06-09 10:20:57 +02:00
|
|
|
ios_user:
|
2017-07-26 16:09:17 +02:00
|
|
|
aggregate:
|
2017-06-16 08:28:06 +02:00
|
|
|
- name: ansibletest2
|
|
|
|
- name: ansibletest3
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-09 10:20:57 +02:00
|
|
|
state: present
|
|
|
|
view: network-admin
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-06-16 08:28:06 +02:00
|
|
|
- 'result.commands == ["username ansibletest2 view network-admin", "username ansibletest3 view network-admin"]'
|
|
|
|
|
|
|
|
- name: Add user again (Idempotent)
|
2019-05-28 14:08:37 +02:00
|
|
|
become: true
|
2017-06-16 08:28:06 +02:00
|
|
|
ios_user:
|
|
|
|
name: ansibletest1
|
|
|
|
privilege: 15
|
|
|
|
role: network-operator
|
|
|
|
state: present
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-16 08:28:06 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
- 'result.commands | length == 0'
|
|
|
|
|
|
|
|
- name: Add collection of users again (Idempotent)
|
2019-05-28 14:08:37 +02:00
|
|
|
become: true
|
2017-06-16 08:28:06 +02:00
|
|
|
ios_user:
|
2017-07-26 16:09:17 +02:00
|
|
|
aggregate:
|
2017-09-09 14:33:24 +02:00
|
|
|
- name: ansibletest2
|
2017-06-16 08:28:06 +02:00
|
|
|
- name: ansibletest3
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-16 08:28:06 +02:00
|
|
|
state: present
|
|
|
|
view: network-admin
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
- 'result.commands | length == 0'
|
2017-06-09 10:20:57 +02:00
|
|
|
|
2018-10-31 12:21:46 +01:00
|
|
|
- name: Create user with password_type (password)
|
2019-05-28 14:08:37 +02:00
|
|
|
become: true
|
2018-10-31 12:21:46 +01:00
|
|
|
ios_user:
|
|
|
|
name: ansibleuser4
|
|
|
|
password_type: password
|
|
|
|
configured_password: testpass
|
2019-05-28 14:08:37 +02:00
|
|
|
provider: "{{ cli }}"
|
2018-10-31 12:21:46 +01:00
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- "'username ansibleuser4 password' in result.commands[0]"
|
|
|
|
|
|
|
|
- name: Create user with password_type (secret)
|
2019-05-28 14:08:37 +02:00
|
|
|
become: true
|
2018-10-31 12:21:46 +01:00
|
|
|
ios_user:
|
|
|
|
name: ansibleuser5
|
|
|
|
password_type: secret
|
|
|
|
configured_password: testpass
|
2019-05-28 14:08:37 +02:00
|
|
|
provider: "{{ cli }}"
|
2018-10-31 12:21:46 +01:00
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- "'username ansibleuser5 secret' in result.commands[0]"
|
|
|
|
|
2018-12-12 17:52:15 +01:00
|
|
|
- name: Create user with hashed_password
|
2019-05-28 14:08:37 +02:00
|
|
|
become: true
|
2018-12-12 17:52:15 +01:00
|
|
|
ios_user:
|
|
|
|
name: ansibleuser6
|
|
|
|
hashed_password:
|
|
|
|
type: 5
|
|
|
|
value: $3$8JcDilcYgFZi.yz4ApaqkHG2.8/
|
2019-05-28 14:08:37 +02:00
|
|
|
provider: "{{ cli }}"
|
2018-12-12 17:52:15 +01:00
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
|
|
|
- "'username ansibleuser6 secret' in result.commands[0]"
|
|
|
|
|
2017-06-09 10:20:57 +02:00
|
|
|
- name: tearDown
|
2019-05-28 14:08:37 +02:00
|
|
|
become: true
|
2017-06-09 10:20:57 +02:00
|
|
|
ios_user:
|
2017-07-26 16:09:17 +02:00
|
|
|
aggregate:
|
2017-06-16 08:28:06 +02:00
|
|
|
- name: ansibletest1
|
|
|
|
- name: ansibletest2
|
|
|
|
- name: ansibletest3
|
2018-10-31 12:21:46 +01:00
|
|
|
- name: ansibletest4
|
|
|
|
- name: ansibletest5
|
2018-12-12 17:52:15 +01:00
|
|
|
- name: ansibletest6
|
2017-06-16 08:28:06 +02:00
|
|
|
state: absent
|
2018-02-02 15:50:15 +01:00
|
|
|
provider: "{{ cli }}"
|
2017-06-09 10:20:57 +02:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2018-02-02 15:50:15 +01:00
|
|
|
- '"no username ansibletest1" in result.commands[0]["command"]'
|
2018-08-31 07:38:46 +02:00
|
|
|
- '"no username ansibletest2" in result.commands[1]["command"]'
|
|
|
|
- '"no username ansibletest3" in result.commands[2]["command"]'
|