2018-01-21 21:54:12 +00:00
|
|
|
---
|
|
|
|
# Copyright (c) 2018, René Moser <mail@renemoser.net>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
- name: setup
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
- name: verify setup
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is success
|
|
|
|
|
|
|
|
- name: test fail if missing name
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
2018-01-21 21:54:12 +00:00
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
- name: verify test fail if missing name
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is failed
|
|
|
|
- 'result.msg == "missing required arguments: name"'
|
|
|
|
|
|
|
|
- name: test fail if missing params for state=present
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
- name: verify fail if missing params for state=present
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is failed
|
|
|
|
- 'result.msg.startswith("state is present but all of the following are missing")'
|
|
|
|
|
|
|
|
- name: test fail param not in choices
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
email: john.doe@example.com
|
|
|
|
password: s3cr3t
|
|
|
|
acls:
|
|
|
|
- bad
|
|
|
|
- dns
|
|
|
|
- manage_users
|
|
|
|
register: result
|
|
|
|
ignore_errors: yes
|
|
|
|
- name: verify test fail if missing name
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is failed
|
|
|
|
- 'result.msg.startswith("value of acls must be one or more of")'
|
|
|
|
|
|
|
|
- name: test create user in check mode
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
email: john.doe@example.com
|
|
|
|
password: s3cr3t
|
|
|
|
acls:
|
|
|
|
- upgrade
|
|
|
|
- dns
|
|
|
|
- manage_users
|
|
|
|
register: result
|
|
|
|
check_mode: yes
|
|
|
|
- name: verify test create user in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
|
|
|
|
|
|
|
- name: test create user
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
email: john.doe@example.com
|
|
|
|
password: s3cr3t
|
|
|
|
acls:
|
|
|
|
- upgrade
|
|
|
|
- dns
|
|
|
|
- manage_users
|
|
|
|
register: result
|
|
|
|
- name: verify test create user
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 08:21:50 +00:00
|
|
|
- result.vultr_user.name == '{{ vultr_user_name }}'
|
2018-01-21 21:54:12 +00:00
|
|
|
- result.vultr_user.email == 'john.doe@example.com'
|
|
|
|
- result.vultr_user.api_enabled == true
|
|
|
|
- "'upgrade' in result.vultr_user.acls"
|
|
|
|
- "'manage_users' in result.vultr_user.acls"
|
|
|
|
- "'dns' in result.vultr_user.acls"
|
|
|
|
- result.vultr_user.api_key is defined
|
|
|
|
|
|
|
|
- name: test create user idempotence
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
email: john.doe@example.com
|
|
|
|
password: s3cr3t
|
|
|
|
acls:
|
|
|
|
- upgrade
|
|
|
|
- dns
|
|
|
|
- manage_users
|
|
|
|
register: result
|
|
|
|
- name: verify test create user idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
2018-08-13 08:21:50 +00:00
|
|
|
- result.vultr_user.name == '{{ vultr_user_name }}'
|
2018-01-21 21:54:12 +00:00
|
|
|
- result.vultr_user.email == 'john.doe@example.com'
|
|
|
|
- result.vultr_user.api_enabled == true
|
|
|
|
- "'upgrade' in result.vultr_user.acls"
|
|
|
|
- "'manage_users' in result.vultr_user.acls"
|
|
|
|
- "'dns' in result.vultr_user.acls"
|
|
|
|
- result.vultr_user.api_key is not defined
|
|
|
|
|
|
|
|
- name: test update user in check mode
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
email: jimmy@example.com
|
|
|
|
password: s3cr3t
|
|
|
|
api_enabled: false
|
|
|
|
acls:
|
|
|
|
- manage_users
|
|
|
|
- upgrade
|
|
|
|
- support
|
|
|
|
register: result
|
|
|
|
check_mode: yes
|
|
|
|
- name: verify test update user in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 08:21:50 +00:00
|
|
|
- result.vultr_user.name == '{{ vultr_user_name }}'
|
2018-01-21 21:54:12 +00:00
|
|
|
- result.vultr_user.email == 'john.doe@example.com'
|
|
|
|
- "'upgrade' in result.vultr_user.acls"
|
|
|
|
- "'manage_users' in result.vultr_user.acls"
|
|
|
|
- "'dns' in result.vultr_user.acls"
|
|
|
|
- result.vultr_user.api_enabled == true
|
|
|
|
- result.vultr_user.api_key is not defined
|
|
|
|
|
|
|
|
- name: test update user
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
email: jimmy@example.com
|
|
|
|
password: s3cr3t
|
|
|
|
api_enabled: false
|
|
|
|
acls:
|
|
|
|
- manage_users
|
|
|
|
- upgrade
|
|
|
|
- support
|
|
|
|
register: result
|
|
|
|
- name: verify test update user
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 08:21:50 +00:00
|
|
|
- result.vultr_user.name == '{{ vultr_user_name }}'
|
2018-01-21 21:54:12 +00:00
|
|
|
- result.vultr_user.email == 'jimmy@example.com'
|
|
|
|
- "'upgrade' in result.vultr_user.acls"
|
|
|
|
- "'manage_users' in result.vultr_user.acls"
|
|
|
|
- "'support' in result.vultr_user.acls"
|
|
|
|
- result.vultr_user.api_enabled == false
|
|
|
|
- result.vultr_user.api_key is not defined
|
|
|
|
|
|
|
|
- name: test update user idempotence
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
email: jimmy@example.com
|
|
|
|
password: s3cr3t
|
|
|
|
api_enabled: false
|
|
|
|
acls:
|
|
|
|
- manage_users
|
|
|
|
- upgrade
|
|
|
|
- support
|
|
|
|
register: result
|
|
|
|
- name: verify test update user idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
2018-08-13 08:21:50 +00:00
|
|
|
- result.vultr_user.name == '{{ vultr_user_name }}'
|
2018-01-21 21:54:12 +00:00
|
|
|
- result.vultr_user.email == 'jimmy@example.com'
|
|
|
|
- "'upgrade' in result.vultr_user.acls"
|
|
|
|
- "'manage_users' in result.vultr_user.acls"
|
|
|
|
- "'support' in result.vultr_user.acls"
|
|
|
|
- result.vultr_user.api_enabled == false
|
|
|
|
- result.vultr_user.api_key is not defined
|
|
|
|
|
|
|
|
- name: test absent user in check mode
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
check_mode: yes
|
|
|
|
- name: verify test absent user in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 08:21:50 +00:00
|
|
|
- result.vultr_user.name == '{{ vultr_user_name }}'
|
2018-01-21 21:54:12 +00:00
|
|
|
- result.vultr_user.email == 'jimmy@example.com'
|
|
|
|
- "'upgrade' in result.vultr_user.acls"
|
|
|
|
- "'manage_users' in result.vultr_user.acls"
|
|
|
|
- "'support' in result.vultr_user.acls"
|
|
|
|
- result.vultr_user.api_enabled == false
|
|
|
|
- result.vultr_user.api_key is not defined
|
|
|
|
|
|
|
|
- name: test absent user
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
- name: verify test absent user
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 08:21:50 +00:00
|
|
|
- result.vultr_user.name == '{{ vultr_user_name }}'
|
2018-01-21 21:54:12 +00:00
|
|
|
- result.vultr_user.email == 'jimmy@example.com'
|
|
|
|
- "'upgrade' in result.vultr_user.acls"
|
|
|
|
- "'manage_users' in result.vultr_user.acls"
|
|
|
|
- "'support' in result.vultr_user.acls"
|
|
|
|
- result.vultr_user.api_enabled == false
|
|
|
|
- result.vultr_user.api_key is not defined
|
|
|
|
|
|
|
|
- name: test absent user idempotence
|
2018-08-13 08:21:50 +00:00
|
|
|
vultr_user:
|
|
|
|
name: "{{ vultr_user_name }}"
|
2018-01-21 21:54:12 +00:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
- name: verify test absent user idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|