2017-06-09 08:20:57 +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
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
|
|
|
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:
|
|
|
|
users:
|
2017-06-16 06:28:06 +00:00
|
|
|
- name: ansibletest2
|
|
|
|
- name: ansibletest3
|
2017-06-09 08:20:57 +00:00
|
|
|
authorize: yes
|
|
|
|
state: present
|
|
|
|
view: network-admin
|
|
|
|
provider: "{{ cli }}"
|
|
|
|
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
|
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
- 'result.commands | length == 0'
|
|
|
|
|
|
|
|
- name: Add collection of users again (Idempotent)
|
|
|
|
ios_user:
|
|
|
|
users:
|
|
|
|
- name: anisbletest2
|
|
|
|
- name: ansibletest3
|
|
|
|
authorize: yes
|
|
|
|
state: present
|
|
|
|
view: network-admin
|
|
|
|
provider: "{{ cli }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == false'
|
|
|
|
- 'result.commands | length == 0'
|
2017-06-09 08:20:57 +00:00
|
|
|
|
|
|
|
- name: tearDown
|
|
|
|
ios_user:
|
2017-06-16 06:28:06 +00:00
|
|
|
users:
|
|
|
|
- name: ansibletest1
|
|
|
|
- name: ansibletest2
|
|
|
|
- name: ansibletest3
|
|
|
|
state: absent
|
2017-06-09 08:20:57 +00:00
|
|
|
authorize: yes
|
|
|
|
provider: "{{ cli }}"
|
|
|
|
register: result
|
|
|
|
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- 'result.changed == true'
|
2017-06-16 06:28:06 +00:00
|
|
|
- 'result.commands == ["no username ansibletest1", "no username ansibletest2", "no username ansibletest3"]'
|