vultr: add integration tests (#35157)

pull/35158/head
René Moser 7 years ago committed by GitHub
parent 8071cc0529
commit d1ce8e9924
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,24 @@
# 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: test gather vultr account facts in check mode
vr_account_facts:
check_mode: yes
- name: verify test gather vultr account facts in check mode
assert:
that:
- ansible_facts.vultr_account_facts.balance is defined
- ansible_facts.vultr_account_facts.last_payment_amount is defined
- ansible_facts.vultr_account_facts.last_payment_date is defined
- ansible_facts.vultr_account_facts.last_payment_amount is defined
- name: test gather vultr account fact
vr_account_facts:
- name: verify test gather vultr account facts
assert:
that:
- ansible_facts.vultr_account_facts.balance is defined
- ansible_facts.vultr_account_facts.last_payment_amount is defined
- ansible_facts.vultr_account_facts.last_payment_date is defined
- ansible_facts.vultr_account_facts.last_payment_amount is defined

@ -0,0 +1,4 @@
# 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)
---
vr_dns_domain_name: example-ansible.com

@ -0,0 +1,99 @@
# 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
vr_dns_domain:
name: "{{ vr_dns_domain_name }}"
state: absent
register: result
- name: verify setup
assert:
that:
- result is success
- name: test fail if missing name
vr_dns_domain:
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
vr_dns_domain:
name: "{{ vr_dns_domain_name }}"
register: result
ignore_errors: yes
- name: verify fail if missing params for state=present
assert:
that:
- result is failed
- 'result.msg == "state is present but all of the following are missing: server_ip"'
- name: test create dns domain in check mode
vr_dns_domain:
name: "{{ vr_dns_domain_name }}"
server_ip: 10.10.10.10
register: result
check_mode: yes
- name: verify test create dns domain in check mode
assert:
that:
- result is changed
- name: test create dns domain
vr_dns_domain:
name: "{{ vr_dns_domain_name }}"
server_ip: 10.10.10.10
register: result
- name: verify test create dns domain
assert:
that:
- result is changed
- result.vultr_dns_domain.name == '{{ vr_dns_domain_name }}'
- name: test create dns domain idempotence
vr_dns_domain:
name: "{{ vr_dns_domain_name }}"
server_ip: 10.10.10.10
register: result
- name: verify test create dns domain idempotence
assert:
that:
- result is not changed
- result.vultr_dns_domain.name == '{{ vr_dns_domain_name }}'
- name: test absent dns domain in check mode
vr_dns_domain:
name: "{{ vr_dns_domain_name }}"
state: absent
register: result
check_mode: yes
- name: verify test absent dns domain in check mode
assert:
that:
- result is changed
- result.vultr_dns_domain.name == '{{ vr_dns_domain_name }}'
- name: test absent dns domain
vr_dns_domain:
name: "{{ vr_dns_domain_name }}"
state: absent
register: result
- name: verify test absent dns domain
assert:
that:
- result is changed
- result.vultr_dns_domain.name == '{{ vr_dns_domain_name }}'
- name: test absent dns domain idempotence
vr_dns_domain:
name: "{{ vr_dns_domain_name }}"
state: absent
register: result
- name: verify test absent dns domain idempotence
assert:
that:
- result is not changed

@ -1,3 +1,5 @@
# 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)
--- ---
vr_dns_domain_name: example-ansible.com vr_dns_domain_name: example-ansible.com
vr_dns_record_items: vr_dns_record_items:

@ -1,3 +1,5 @@
# 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: test setup dns record - name: test setup dns record
vr_dns_record: vr_dns_record:

@ -1,3 +1,5 @@
# 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 dns domain - name: setup dns domain
vr_dns_domain: vr_dns_domain:

@ -1,3 +1,5 @@
# 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)
--- ---
- include_tasks: create_record.yml - include_tasks: create_record.yml
- include_tasks: update_record.yml - include_tasks: update_record.yml

@ -1,3 +1,5 @@
# 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: test remove a dns record in check mode - name: test remove a dns record in check mode
vr_dns_record: vr_dns_record:

@ -1,3 +1,5 @@
# 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 first dns record - name: setup first dns record
vr_dns_record: vr_dns_record:

@ -1,3 +1,5 @@
# 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: test update or add another dns record in check mode - name: test update or add another dns record in check mode
vr_dns_record: vr_dns_record:

@ -0,0 +1,4 @@
# 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)
---
vr_firewall_group_name: ansible-firewall-group

@ -0,0 +1,86 @@
# 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
vr_firewall_group:
name: "{{ vr_firewall_group_name }}"
state: absent
register: result
- name: verify setup
assert:
that:
- result is success
- name: test fail if missing name
vr_firewall_group:
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 create firewall group in check mode
vr_firewall_group:
name: "{{ vr_firewall_group_name }}"
register: result
check_mode: yes
- name: verify test create firewall group in check mode
assert:
that:
- result is changed
- name: test create firewall group
vr_firewall_group:
name: "{{ vr_firewall_group_name }}"
register: result
- name: verify test create firewall group
assert:
that:
- result is changed
- result.vultr_firewall_group.name == '{{ vr_firewall_group_name }}'
- name: test create firewall group idempotence
vr_firewall_group:
name: "{{ vr_firewall_group_name }}"
register: result
- name: verify test create firewall group idempotence
assert:
that:
- result is not changed
- result.vultr_firewall_group.name == '{{ vr_firewall_group_name }}'
- name: test absent firewall group in check mode
vr_firewall_group:
name: "{{ vr_firewall_group_name }}"
state: absent
register: result
check_mode: yes
- name: verify test absent firewall group in check mode
assert:
that:
- result is changed
- result.vultr_firewall_group.name == '{{ vr_firewall_group_name }}'
- name: test absent firewall group
vr_firewall_group:
name: "{{ vr_firewall_group_name }}"
state: absent
register: result
- name: verify test absent firewall group
assert:
that:
- result is changed
- result.vultr_firewall_group.name == '{{ vr_firewall_group_name }}'
- name: test absent firewall group idempotence
vr_firewall_group:
name: "{{ vr_firewall_group_name }}"
state: absent
register: result
- name: verify test absent firewall group idempotence
assert:
that:
- result is not changed

@ -0,0 +1,4 @@
# 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)
---
vr_firewall_group_name: ansible-firewall-group

@ -0,0 +1,475 @@
# 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 firewall group
vr_firewall_group:
name: "{{ vr_firewall_group_name }}"
register: result
- name: verify setup firewall group
assert:
that:
- result is success
- name: setup firewall rule tcp
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
state: absent
register: result
- name: verify setup firewal rule
assert:
that:
- result is success
- name: setup firewall rule udp
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
state: absent
register: result
- name: verify setup firewal rule udp
assert:
that:
- result is success
- name: setup firewall rule udp v6
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
ip_version: v6
state: absent
register: result
- name: verify setup firewal rule udp v6
assert:
that:
- result is success
- name: setup firewall rule port range
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
start_port: 8000
end_port: 8080
protocol: tcp
cidr: 10.100.12.0/24
state: absent
register: result
tags: tmp
- name: verify setup firewal rule port range
assert:
that:
- result is success
- name: setup firewall rule icmp
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
protocol: icmp
state: absent
register: result
- name: verify setup firewal rule
assert:
that:
- result is success
- name: test fail if missing group
vr_firewall_rule:
register: result
ignore_errors: yes
- name: verify test fail if missing group
assert:
that:
- result is failed
- 'result.msg == "missing required arguments: group"'
- name: test create firewall rule tcp in check mode
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
register: result
check_mode: true
- name: verify test create firewall rule tcp in check mode
assert:
that:
- result is changed
- name: test create firewall rule tcp
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
register: result
- name: verify test create firewall rule tcp
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "tcp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "0.0.0.0/0"
- name: test create firewall rule tcp idempotence
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
register: result
- name: verify test create firewall rule tcp idempotence
assert:
that:
- result is not changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "tcp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "0.0.0.0/0"
- name: test create firewall rule udp in check mode
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
register: result
check_mode: true
- name: verify test create firewall rule udp in check mode
assert:
that:
- result is changed
- name: test create firewall rule udp
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
register: result
- name: verify test create firewall rule udp
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "udp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "0.0.0.0/0"
- name: test create firewall rule udp idempotence
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
register: result
- name: verify test create firewall rule udp idempotence
assert:
that:
- result is not changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "udp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "0.0.0.0/0"
- name: test create firewall rule udp v6 in check mode
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
ip_version: v6
register: result
check_mode: true
- name: verify test create firewall rule udp v6 in check mode
assert:
that:
- result is changed
- name: test create firewall rule udp v6
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
ip_version: v6
register: result
- name: verify test create firewall rule udp v6
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "udp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "::/0"
- name: test create firewall rule udp v6 idempotence
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
ip_version: v6
register: result
- name: verify test create firewall rule udp v6 idempotence
assert:
that:
- result is not changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "udp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "::/0"
- name: test create firewall rule port range in check mode
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
start_port: 8000
end_port: 8080
protocol: tcp
cidr: 10.100.12.0/24
register: result
check_mode: true
- name: verify test create firewall rule port range in check mode
assert:
that:
- result is changed
- name: test create firewall rule port range
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
start_port: 8000
end_port: 8080
protocol: tcp
cidr: 10.100.12.0/24
register: result
- name: verify test create firewall rule port range
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "tcp"
- result.vultr_firewall_rule.start_port == 8000
- result.vultr_firewall_rule.end_port == 8080
- result.vultr_firewall_rule.cidr == "10.100.12.0/24"
- name: test create firewall rule port range idempotence
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
start_port: 8000
end_port: 8080
protocol: tcp
cidr: 10.100.12.0/24
register: result
- name: test create firewall rule port range idempotence
assert:
that:
- result is not changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "tcp"
- result.vultr_firewall_rule.start_port == 8000
- result.vultr_firewall_rule.end_port == 8080
- result.vultr_firewall_rule.cidr == "10.100.12.0/24"
- name: test create firewall rule icmp in check mode
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
protocol: icmp
register: result
check_mode: true
- name: test create firewall rule icmp in check mode
assert:
that:
- result is changed
- name: test create firewall rule icmp
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
protocol: icmp
register: result
- name: test create firewall rule icmp
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "icmp"
- name: test create firewall rule icmp idempotence
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
protocol: icmp
register: result
- name: test create firewall rule icmp idempotence
assert:
that:
- result is not changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "icmp"
- name: test remove firewall rule icmp in check mode
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
protocol: icmp
state: absent
register: result
check_mode: true
- name: test remove firewall rule icmp in check mode
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "icmp"
- name: test remove firewall rule icmp
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
protocol: icmp
state: absent
register: result
- name: test remove firewall rule icmp
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "icmp"
- name: test remove firewall rule icmp idempotence
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
protocol: icmp
state: absent
register: result
- name: test remove firewall rule icmp idempotence
assert:
that:
- result is not changed
- name: test remove firewall rule tcp in check mode
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
state: absent
register: result
check_mode: true
- name: verify test remove firewall rule tcp in check mode
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "tcp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "0.0.0.0/0"
- name: test remove firewall rule tcp
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
state: absent
register: result
- name: verify test remove firewall rule tcp
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "tcp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "0.0.0.0/0"
- name: test remove firewall rule tcp idempotence
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
state: absent
register: result
- name: verify test remove firewall rule tcp idempotence
assert:
that:
- result is not changed
- name: test remove firewall rule udp v6 in check mode
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
ip_version: v6
state: absent
register: result
check_mode: true
- name: verify test remove firewall rule udp v6 in check mode
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "udp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "::/0"
- name: test remove firewall rule udp v6
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
ip_version: v6
state: absent
register: result
- name: verify test remove firewall rule udp v6
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "udp"
- result.vultr_firewall_rule.start_port == 53
- result.vultr_firewall_rule.cidr == "::/0"
- name: test remove firewall rule udp v6 idempotence
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
port: 53
protocol: udp
ip_version: v6
state: absent
register: result
- name: verify test remove firewall rule udp v6 idempotence
assert:
that:
- result is not changed
- name: test remove firewall rule port range in check mode
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
start_port: 8000
end_port: 8080
protocol: tcp
cidr: 10.100.12.0/24
state: absent
register: result
check_mode: true
- name: verify test remove firewall rule port range in check mode
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "tcp"
- result.vultr_firewall_rule.start_port == 8000
- result.vultr_firewall_rule.end_port == 8080
- result.vultr_firewall_rule.cidr == "10.100.12.0/24"
- name: test remove firewall rule port range
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
start_port: 8000
end_port: 8080
protocol: tcp
cidr: 10.100.12.0/24
state: absent
register: result
- name: verify test remove firewall rule port range
assert:
that:
- result is changed
- result.vultr_firewall_rule.action == "accept"
- result.vultr_firewall_rule.protocol == "tcp"
- result.vultr_firewall_rule.start_port == 8000
- result.vultr_firewall_rule.end_port == 8080
- result.vultr_firewall_rule.cidr == "10.100.12.0/24"
- name: test remove firewall rule port range idempotence
vr_firewall_rule:
group: "{{ vr_firewall_group_name }}"
start_port: 8000
end_port: 8080
protocol: tcp
cidr: 10.100.12.0/24
state: absent
register: result
- name: verify test remove firewall rule port range idempotence
assert:
that:
- result is not changed

@ -0,0 +1,4 @@
# 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)
---
vr_server_name: ansible-test-vm1

@ -0,0 +1,481 @@
# 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
vr_server:
name: "{{ vr_server_name }}"
state: absent
register: result
- name: verify setup
assert:
that:
- result is success
- name: test fail if missing name
vr_server:
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
vr_server:
name: "{{ vr_server_name }}"
register: result
ignore_errors: yes
- name: verify fail if missing params for state=present
assert:
that:
- result is failed
- 'result.msg == "missing required arguments: os, plan, region"'
- name: test create server in check mode
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 1024 MB RAM,25 GB SSD,1.00 TB BW
region: Amsterdam
state: started
register: result
check_mode: yes
- name: verify test create server in check mode
assert:
that:
- result is changed
- name: test create server
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 1024 MB RAM,25 GB SSD,1.00 TB BW
region: Amsterdam
state: started
register: result
- name: verify test create server
assert:
that:
- result is changed
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '1024 MB RAM,25 GB SSD,1.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.power_status == 'running'
- name: test create server idempotence
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 1024 MB RAM,25 GB SSD,1.00 TB BW
region: Amsterdam
state: started
register: result
- name: verify test create server idempotence
assert:
that:
- result is not changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '1024 MB RAM,25 GB SSD,1.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- name: test stop an existing server in check mode
vr_server:
name: "{{ vr_server_name }}"
state: stopped
register: result
check_mode: yes
- name: verify test stop server in check mode
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- name: test stop an existing server
vr_server:
name: "{{ vr_server_name }}"
state: stopped
register: result
- name: verify test stop an existing server
assert:
that:
- result is changed
- result.vultr_server.power_status == 'stopped'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- name: test stop an existing server idempotence
vr_server:
name: "{{ vr_server_name }}"
state: stopped
register: result
- name: verify test stop an existing server idempotence
assert:
that:
- result is not changed
- result.vultr_server.power_status == 'stopped'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- name: test start an existing server in check mode
vr_server:
name: "{{ vr_server_name }}"
state: started
register: result
check_mode: yes
- name: verify test start an existing server in check mode
assert:
that:
- result is changed
- result.vultr_server.power_status == 'stopped'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- name: test start an existing server
vr_server:
name: "{{ vr_server_name }}"
state: started
register: result
- name: verify test start an existing server
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- name: test start an existing server idempotence
vr_server:
name: "{{ vr_server_name }}"
state: started
register: result
- name: verify test start an existing server idempotence
assert:
that:
- result is not changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- name: test update plan for server in check mode without force
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 2048 MB RAM,40 GB SSD,2.00 TB BW
region: Amsterdam
register: result
check_mode: yes
- name: verify test update plan for server in check mode without force
assert:
that:
- result is not changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '1024 MB RAM,25 GB SSD,1.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- name: test update plan for server without force
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 2048 MB RAM,40 GB SSD,2.00 TB BW
region: Amsterdam
register: result
- name: verify test update plan for server without force
assert:
that:
- result is not changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '1024 MB RAM,25 GB SSD,1.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- name: setup firewall group
vr_firewall_group:
name: test_firewall_group
register: result
- name: verify test create firewall group
assert:
that:
- result is success
- name: test fail with unknown firewall group
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
region: Amsterdam
firewall_group: does not exist
tag: test_tag
register: result
ignore_errors: yes
check_mode: yes
- name: verify test fail with unknown firewall group
assert:
that:
- result is failed
- result.msg.startswith('Could not find')
- name: test update tag, firewall group for server in check mode without force
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
region: Amsterdam
firewall_group: test_firewall_group
tag: test_tag
register: result
check_mode: yes
- name: verify test update tag, firewall group for server in check mode without force
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '1024 MB RAM,25 GB SSD,1.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.tag == ''
- result.vultr_server.firewall_group != 'test_firewall_group'
- name: test update tag, firewall group for server without force
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
region: Amsterdam
firewall_group: test_firewall_group
tag: test_tag
register: result
- name: verify test update tag, firewall group for server without force
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.tag == 'test_tag'
- result.vultr_server.firewall_group == 'test_firewall_group'
- name: test update tag, firewall group for server without force idempotence
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
region: Amsterdam
firewall_group: test_firewall_group
tag: test_tag
register: result
- name: verify test update tag, firewall group for server without force idempotence
assert:
that:
- result is not changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.tag == 'test_tag'
- result.vultr_server.firewall_group == 'test_firewall_group'
- name: test update server in check mode with force
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 2048 MB RAM,40 GB SSD,2.00 TB BW
auto_backup_enabled: yes
region: Amsterdam
force: yes
register: result
check_mode: yes
- name: verify test update server in check mode with force
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '1024 MB RAM,25 GB SSD,1.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.auto_backup_enabled == false
- name: test update server with force
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 2048 MB RAM,40 GB SSD,2.00 TB BW
auto_backup_enabled: yes
region: Amsterdam
force: yes
register: result
- name: verify test update server with force
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '2048 MB RAM,40 GB SSD,2.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.auto_backup_enabled == true
- name: test update server idempotence with force
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 2048 MB RAM,40 GB SSD,2.00 TB BW
auto_backup_enabled: true
region: Amsterdam
force: true
register: result
- name: verify test update server idempotence with force
assert:
that:
- result is not changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '2048 MB RAM,40 GB SSD,2.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.auto_backup_enabled == true
- name: test update server to stopped in check mode
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 2048 MB RAM,40 GB SSD,2.00 TB BW
ipv6_enabled: true
region: Amsterdam
state: stopped
register: result
check_mode: yes
- name: verify test update server to stopped in check mode
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '2048 MB RAM,40 GB SSD,2.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.v6_main_ip == ''
- name: test update server to stopped
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 2048 MB RAM,40 GB SSD,2.00 TB BW
ipv6_enabled: true
region: Amsterdam
state: stopped
register: result
- name: verify test update server to stopped
assert:
that:
- result is changed
- result.vultr_server.power_status == 'stopped'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '2048 MB RAM,40 GB SSD,2.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.v6_main_ip != ''
- name: test update server to stopped idempotence
vr_server:
name: "{{ vr_server_name }}"
os: CentOS 6 x64
plan: 2048 MB RAM,40 GB SSD,2.00 TB BW
region: Amsterdam
state: stopped
register: result
- name: verify test update server to stopped idempotence
assert:
that:
- result is not changed
- result.vultr_server.power_status == 'stopped'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.plan == '2048 MB RAM,40 GB SSD,2.00 TB BW'
- result.vultr_server.region == 'Amsterdam'
- result.vultr_server.v6_main_ip != ''
- name: test restart an existing server in check mode
vr_server:
name: "{{ vr_server_name }}"
state: restarted
register: result
check_mode: yes
- name: verify test restart an existing server in check mode
assert:
that:
- result is changed
- result.vultr_server.power_status == 'stopped'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- name: test restart an existing server
vr_server:
name: "{{ vr_server_name }}"
state: restarted
register: result
- name: verify test restart an existing server
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- name: test absent server in check mode
vr_server:
name: "{{ vr_server_name }}"
state: absent
register: result
check_mode: yes
- name: verify test absent server in check mode
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
# Servers can only be destroyed 5 min after creation
- name: wait for 5 min
local_action: wait_for
- name: test absent server
vr_server:
name: "{{ vr_server_name }}"
state: absent
register: result
- name: verify test absent server
assert:
that:
- result is changed
- result.vultr_server.power_status == 'running'
- result.vultr_server.name == '{{ vr_server_name }}'
- result.vultr_server.os == 'CentOS 6 x64'
- result.vultr_server.region == 'Amsterdam'
- name: test absent server idempotence
vr_server:
name: "{{ vr_server_name }}"
state: absent
register: result
- name: verify test absent server idempotence
assert:
that:
- result is not changed

@ -0,0 +1,6 @@
# 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)
---
vr_ssh_key_name: ansible-ssh-key
vr_ssh_key: "ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAgEAyWYItY+3w5b8PdGRoz0oY5mufqydW96naE+VM3JSvJFAUS08rAjQQpQ03ymoALeHQy6JVZbcgecxn6p0pAOINQdqufn4udPtOPCtMjNiPGpkSM9ah/6X5+kvyWMNrvlf+Ld4OOoszP5sAkgQzIbrFQAm41XknBUha0zkewZwfrVhain4pnDjV7wCcChId/Q/Gbi4xMtXkisznWcAJcueBs3EEZDKhJ5q0VeWSJEhYJDLFN1sOxF0AIUnMrOhfKQ/LjgREXPB6uCl899INUTXRNNjRpeMXyJ2wMMmOAbua2qEd1r13Bu1n+6A823Hzb33fyMXuqWnJwBJ4DCvMlGuEsfuOK+xk7DaBfLHbcM6fsPk0/4psTE6YLgC41remr6+u5ZWsY/faMtSnNPie8Z8Ov0DIYGdhbJjUXk1HomxRV9+ZfZ2Ob8iCwlaAQAyEUM6fs3Kxt8pBD8dx1HOkhsfBWPvuDr5y+kqE7H8/MuPDTc0QgH2pjUMpmw/XBwNDHshVEjrZvtICOjOLUJxcowLO1ivNYwPwowQxfisMy56LfYdjsOslBiqsrkAqvNGm1zu8wKHeqVN9w5l3yUELpvubfm9NKIvYcl6yWF36T0c5vE+g0DU/Jy4XpTj0hZG9QV2mRQcLJnd2pxQtJT7cPFtrn/+tgRxzjEtbDXummDV4sE= ansible@example.com"
vr_ssh_key2: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCoQ9S7V+CufAgwoehnf2TqsJ9LTsu8pUA3FgpS2mdVwcMcTs++8P5sQcXHLtDmNLpWN4k7NQgxaY1oXy5e25x/4VhXaJXWEt3luSw+Phv/PB2+aGLvqCUirsLTAD2r7ieMhd/pcVf/HlhNUQgnO1mupdbDyqZoGD/uCcJiYav8i/V7nJWJouHA8yq31XS2yqXp9m3VC7UZZHzUsVJA9Us5YqF0hKYeaGruIHR2bwoDF9ZFMss5t6/pzxMljU/ccYwvvRDdI7WX4o4+zLuZ6RWvsU6LGbbb0pQdB72tlV41fSefwFsk4JRdKbyV3Xjf25pV4IXOTcqhy+4JTB/jXxrF torwalds@github.com"

@ -0,0 +1,140 @@
# 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
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
state: absent
register: result
- name: verify setup
assert:
that:
- result is success
- name: test fail if missing name
vr_ssh_key:
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
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
register: result
ignore_errors: yes
- name: verify fail if missing params for state=present
assert:
that:
- result is failed
- 'result.msg == "state is present but all of the following are missing: ssh_key"'
- name: test create ssh key in check mode
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
ssh_key: "{{ vr_ssh_key }}"
register: result
check_mode: yes
- name: verify test create ssh key in check mode
assert:
that:
- result is changed
- name: test create ssh key
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
ssh_key: "{{ vr_ssh_key }}"
register: result
- name: verify test create ssh key
assert:
that:
- result is changed
- result.vultr_ssh_key.name == '{{ vr_ssh_key_name }}'
- result.vultr_ssh_key.ssh_key == '{{ vr_ssh_key }}'
- name: test create ssh key idempotence
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
ssh_key: "{{ vr_ssh_key }}"
register: result
- name: verify test create ssh key idempotence
assert:
that:
- result is not changed
- result.vultr_ssh_key.name == '{{ vr_ssh_key_name }}'
- result.vultr_ssh_key.ssh_key == '{{ vr_ssh_key }}'
- name: test update ssh key in check mode
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
ssh_key: "{{ vr_ssh_key2 }}"
register: result
check_mode: yes
- name: verify test update ssh key in check mode
assert:
that:
- result is changed
- result.vultr_ssh_key.name == '{{ vr_ssh_key_name }}'
- result.vultr_ssh_key.ssh_key == '{{ vr_ssh_key }}'
- name: test update ssh key
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
ssh_key: "{{ vr_ssh_key2 }}"
register: result
- name: verify test update ssh key
assert:
that:
- result is changed
- result.vultr_ssh_key.name == '{{ vr_ssh_key_name }}'
- result.vultr_ssh_key.ssh_key == '{{ vr_ssh_key2 }}'
- name: test update ssh key idempotence
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
ssh_key: "{{ vr_ssh_key2 }}"
register: result
- name: verify test update ssh key idempotence
assert:
that:
- result is not changed
- result.vultr_ssh_key.name == '{{ vr_ssh_key_name }}'
- result.vultr_ssh_key.ssh_key == '{{ vr_ssh_key2 }}'
- name: test absent ssh key in check mode
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
state: absent
register: result
check_mode: yes
- name: verify test absent ssh key in check mode
assert:
that:
- result is changed
- result.vultr_ssh_key.name == '{{ vr_ssh_key_name }}'
- result.vultr_ssh_key.ssh_key == '{{ vr_ssh_key2 }}'
- name: test absent ssh key
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
state: absent
register: result
- name: verify test absent ssh key
assert:
that:
- result is changed
- result.vultr_ssh_key.name == '{{ vr_ssh_key_name }}'
- result.vultr_ssh_key.ssh_key == '{{ vr_ssh_key2 }}'
- name: test absent ssh key idempotence
vr_ssh_key:
name: "{{ vr_ssh_key_name }}"
state: absent
register: result
- name: verify test absent ssh key idempotence
assert:
that:
- result is not changed

@ -1,7 +1,6 @@
---
# Copyright (c) 2018, René Moser <mail@renemoser.net> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
vr_startup_script_name: ansible_test_script vr_startup_script_name: ansible_test_script
vr_startup_script: "#!/bin/bash\necho Hello World > /root/hello" vr_startup_script: "#!/bin/bash\necho Hello World > /root/hello"
vr_startup_script2: "#!/bin/bash\necho Hello to my World > /root/hello" vr_startup_script2: "#!/bin/bash\necho Hello to my World > /root/hello"

@ -1,7 +1,6 @@
---
# Copyright (c) 2018, René Moser <mail@renemoser.net> # 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) # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: setup - name: setup
vr_startup_script: vr_startup_script:
name: "{{ vr_startup_script_name }}" name: "{{ vr_startup_script_name }}"

@ -0,0 +1,4 @@
# 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)
---
vr_user_name: john

@ -0,0 +1,225 @@
---
# 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
vr_user:
name: "{{ vr_user_name }}"
state: absent
register: result
- name: verify setup
assert:
that:
- result is success
- name: test fail if missing name
vr_user:
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
vr_user:
name: "{{ vr_user_name }}"
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
vr_user:
name: "{{ vr_user_name }}"
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
vr_user:
name: "{{ vr_user_name }}"
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
vr_user:
name: "{{ vr_user_name }}"
email: john.doe@example.com
password: s3cr3t
acls:
- upgrade
- dns
- manage_users
register: result
- name: verify test create user
assert:
that:
- result is changed
- result.vultr_user.name == '{{ vr_user_name }}'
- 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
vr_user:
name: "{{ vr_user_name }}"
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
- result.vultr_user.name == '{{ vr_user_name }}'
- 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
vr_user:
name: "{{ vr_user_name }}"
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
- result.vultr_user.name == '{{ vr_user_name }}'
- 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
vr_user:
name: "{{ vr_user_name }}"
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
- result.vultr_user.name == '{{ vr_user_name }}'
- 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
vr_user:
name: "{{ vr_user_name }}"
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
- result.vultr_user.name == '{{ vr_user_name }}'
- 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
vr_user:
name: "{{ vr_user_name }}"
state: absent
register: result
check_mode: yes
- name: verify test absent user in check mode
assert:
that:
- result is changed
- result.vultr_user.name == '{{ vr_user_name }}'
- 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
vr_user:
name: "{{ vr_user_name }}"
state: absent
register: result
- name: verify test absent user
assert:
that:
- result is changed
- result.vultr_user.name == '{{ vr_user_name }}'
- 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
vr_user:
name: "{{ vr_user_name }}"
state: absent
register: result
- name: verify test absent user idempotence
assert:
that:
- result is not changed

@ -0,0 +1,16 @@
# 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)
---
- hosts: localhost
gather_facts: no
connection: local
roles:
- { role: vr_account_facts, tags: test_vr_account_facts }
- { role: vr_user, tags: test_vr_user }
- { role: vr_ssh_key, tags: test_vr_ssh_key }
- { role: vr_firewall_group, tags: test_vr_firewall_group }
- { role: vr_firewall_rule, tags: test_vr_firewall_rule }
- { role: vr_startup_script, tags: test_vr_startup_script }
- { role: vr_dns_domain, tags: test_vr_dns_domain }
- { role: vr_dns_record, tags: test_vr_dns_record }
- { role: vr_server, tags: test_vr_server }
Loading…
Cancel
Save