mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
2.0 KiB
YAML
92 lines
2.0 KiB
YAML
---
|
|
- name: tear down old users if they exist (Setup)
|
|
ios_user:
|
|
aggregate:
|
|
- name: ansibletest1
|
|
- name: ansibletest2
|
|
- name: ansibletest3
|
|
state: absent
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- name: Create user (SetUp)
|
|
ios_user:
|
|
name: ansibletest1
|
|
privilege: 15
|
|
role: network-operator
|
|
state: present
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- 'result.commands == ["username ansibletest1 view network-operator", "username ansibletest1 privilege 15"]'
|
|
|
|
- name: Collection of users (SetUp)
|
|
ios_user:
|
|
aggregate:
|
|
- name: ansibletest2
|
|
- name: ansibletest3
|
|
authorize: yes
|
|
state: present
|
|
view: network-admin
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '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:
|
|
aggregate:
|
|
- name: anisbletest2
|
|
- name: ansibletest3
|
|
authorize: yes
|
|
state: present
|
|
view: network-admin
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == false'
|
|
- 'result.commands | length == 0'
|
|
|
|
- name: tearDown
|
|
ios_user:
|
|
aggregate:
|
|
- name: ansibletest1
|
|
- name: ansibletest2
|
|
- name: ansibletest3
|
|
state: absent
|
|
authorize: yes
|
|
provider: "{{ cli }}"
|
|
register: result
|
|
|
|
- assert:
|
|
that:
|
|
- 'result.changed == true'
|
|
- '"no username ansibletest1" in result.commands[0]'
|
|
- '"no username ansibletest2" in result.commands[1]'
|
|
- '"no username ansibletest3" in result.commands[2]'
|