2017-06-09 08:20:57 +00:00
|
|
|
---
|
2017-08-16 09:45:41 +00:00
|
|
|
- name: tear down old users if they exist (Setup)
|
|
|
|
ios_user:
|
|
|
|
aggregate:
|
|
|
|
- name: ansibletest1
|
|
|
|
- name: ansibletest2
|
|
|
|
- name: ansibletest3
|
|
|
|
state: absent
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2017-08-16 09:45:41 +00:00
|
|
|
|
2017-06-16 06:28:06 +00:00
|
|
|
- name: Create user (SetUp)
|
2017-06-09 08:20:57 +00:00
|
|
|
ios_user:
|
2017-06-16 06:28:06 +00:00
|
|
|
name: ansibletest1
|
2017-06-09 08:20:57 +00:00
|
|
|
privilege: 15
|
|
|
|
role: network-operator
|
|
|
|
state: present
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2017-06-09 08:20:57 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-06-16 06:28:06 +00:00
|
|
|
- 'result.commands == ["username ansibletest1 view network-operator", "username ansibletest1 privilege 15"]'
|
2017-06-09 08:20:57 +00:00
|
|
|
|
2017-06-16 06:28:06 +00:00
|
|
|
- name: Collection of users (SetUp)
|
2017-06-09 08:20:57 +00:00
|
|
|
ios_user:
|
2017-07-26 14:09:17 +00:00
|
|
|
aggregate:
|
2017-06-16 06:28:06 +00:00
|
|
|
- name: ansibletest2
|
|
|
|
- name: ansibletest3
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2017-06-09 08:20:57 +00:00
|
|
|
state: present
|
|
|
|
view: network-admin
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-06-16 06:28:06 +00: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 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2017-06-16 06:28:06 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
- 'result.commands | length == 0'
|
|
|
|
|
|
|
|
- name: Add collection of users again (Idempotent)
|
|
|
|
ios_user:
|
2017-07-26 14:09:17 +00:00
|
|
|
aggregate:
|
2017-09-09 12:33:24 +00:00
|
|
|
- name: ansibletest2
|
2017-06-16 06:28:06 +00:00
|
|
|
- name: ansibletest3
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2017-06-16 06:28:06 +00:00
|
|
|
state: present
|
|
|
|
view: network-admin
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
- 'result.commands | length == 0'
|
2017-06-09 08:20:57 +00:00
|
|
|
|
|
|
|
- name: tearDown
|
|
|
|
ios_user:
|
2017-07-26 14:09:17 +00:00
|
|
|
aggregate:
|
2017-06-16 06:28:06 +00:00
|
|
|
- name: ansibletest1
|
|
|
|
- name: ansibletest2
|
|
|
|
- name: ansibletest3
|
|
|
|
state: absent
|
2018-02-02 14:50:15 +00:00
|
|
|
provider: "{{ cli }}"
|
2017-06-09 08:20:57 +00:00
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2018-02-02 14:50:15 +00:00
|
|
|
- '"no username ansibletest1" in result.commands[0]["command"]'
|
|
|
|
- '"no username ansibletest2" in result.commands[1]["command"]'
|
|
|
|
- '"no username ansibletest3" in result.commands[2]["command"]'
|