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)
|
|
|
|
ios_user:
|
|
|
|
aggregate:
|
|
|
|
- name: ansibletest1
|
|
|
|
- name: ansibletest2
|
|
|
|
- name: ansibletest3
|
|
|
|
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)
|
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)
|
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)
|
|
|
|
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)
|
|
|
|
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
|
|
|
|
|
|
|
- name: tearDown
|
|
|
|
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
|
|
|
|
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-07-19 16:28:52 +02:00
|
|
|
- '"no username ansibletest2" in result.commands[4]["command"]'
|
|
|
|
- '"no username ansibletest3" in result.commands[8]["command"]'
|