2018-01-21 22:54:12 +01: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 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
- name: verify setup
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is success
|
|
|
|
|
2018-09-19 00:01:53 +02:00
|
|
|
# Servers can only be destroyed 5 min after creation
|
|
|
|
- name: wait for 5 min
|
|
|
|
local_action: wait_for
|
|
|
|
when: result is changed
|
|
|
|
|
2018-01-21 22:54:12 +01:00
|
|
|
- name: test fail if missing name
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
2018-01-21 22:54:12 +01: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 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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"'
|
|
|
|
|
2019-01-01 10:11:10 +01:00
|
|
|
- name: setup create ssh keys
|
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
ssh_key: "{{ item.key }}"
|
|
|
|
loop: "{{ vultr_server_ssh_keys }}"
|
|
|
|
|
2018-01-21 22:54:12 +01:00
|
|
|
- name: test create server in check mode
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
os: CentOS 6 x64
|
|
|
|
plan: 1024 MB RAM,25 GB SSD,1.00 TB BW
|
2019-01-01 10:11:10 +01:00
|
|
|
ssh_keys:
|
|
|
|
- key1
|
|
|
|
- key2
|
2018-01-21 22:54:12 +01:00
|
|
|
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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
os: CentOS 6 x64
|
|
|
|
plan: 1024 MB RAM,25 GB SSD,1.00 TB BW
|
2019-01-01 10:11:10 +01:00
|
|
|
ssh_keys:
|
|
|
|
- key1
|
|
|
|
- key2
|
2018-01-21 22:54:12 +01:00
|
|
|
region: Amsterdam
|
|
|
|
state: started
|
|
|
|
register: result
|
|
|
|
- name: verify test create server
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
os: CentOS 6 x64
|
|
|
|
plan: 1024 MB RAM,25 GB SSD,1.00 TB BW
|
2019-01-01 10:11:10 +01:00
|
|
|
ssh_keys:
|
|
|
|
- key1
|
|
|
|
- key2
|
2018-01-21 22:54:12 +01:00
|
|
|
region: Amsterdam
|
|
|
|
state: started
|
|
|
|
register: result
|
|
|
|
- name: verify test create server idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
|
|
|
- result.vultr_server.power_status == 'running'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- result.vultr_server.os == 'CentOS 6 x64'
|
|
|
|
- result.vultr_server.region == 'Amsterdam'
|
|
|
|
|
|
|
|
- name: test stop an existing server
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: stopped
|
|
|
|
register: result
|
|
|
|
- name: verify test stop an existing server
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
|
|
|
- result.vultr_server.power_status == 'stopped'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- result.vultr_server.os == 'CentOS 6 x64'
|
|
|
|
- result.vultr_server.region == 'Amsterdam'
|
|
|
|
|
|
|
|
- name: test stop an existing server idempotence
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: stopped
|
|
|
|
register: result
|
|
|
|
- name: verify test stop an existing server idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
|
|
|
- result.vultr_server.power_status == 'stopped'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- result.vultr_server.os == 'CentOS 6 x64'
|
|
|
|
- result.vultr_server.region == 'Amsterdam'
|
|
|
|
|
|
|
|
- name: test start an existing server in check mode
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- result.vultr_server.os == 'CentOS 6 x64'
|
|
|
|
- result.vultr_server.region == 'Amsterdam'
|
|
|
|
|
|
|
|
- name: test start an existing server
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: started
|
|
|
|
register: result
|
|
|
|
- name: verify test start an existing server
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
|
|
|
- result.vultr_server.power_status == 'running'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- result.vultr_server.os == 'CentOS 6 x64'
|
|
|
|
- result.vultr_server.region == 'Amsterdam'
|
|
|
|
|
|
|
|
- name: test start an existing server idempotence
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: started
|
|
|
|
register: result
|
|
|
|
- name: verify test start an existing server idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
|
|
|
- result.vultr_server.power_status == 'running'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- result.vultr_server.os == 'CentOS 6 x64'
|
|
|
|
- result.vultr_server.region == 'Amsterdam'
|
|
|
|
|
|
|
|
- name: test update plan for server in check mode without force
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_firewall_group:
|
2018-01-21 22:54:12 +01:00
|
|
|
name: test_firewall_group
|
|
|
|
register: result
|
|
|
|
- name: verify test create firewall group
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is success
|
|
|
|
|
|
|
|
- name: test fail with unknown firewall group
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- result.vultr_server.os == 'CentOS 6 x64'
|
|
|
|
- result.vultr_server.region == 'Amsterdam'
|
|
|
|
|
|
|
|
- name: test restart an existing server
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: restarted
|
|
|
|
register: result
|
|
|
|
- name: verify test restart an existing server
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
|
|
|
- result.vultr_server.power_status == 'running'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- result.vultr_server.os == 'CentOS 6 x64'
|
|
|
|
- result.vultr_server.region == 'Amsterdam'
|
|
|
|
|
|
|
|
- name: test absent server in check mode
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
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'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- 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
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
- name: verify test absent server
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is changed
|
|
|
|
- result.vultr_server.power_status == 'running'
|
2018-08-13 10:21:50 +02:00
|
|
|
- result.vultr_server.name == '{{ vultr_server_name }}'
|
2018-01-21 22:54:12 +01:00
|
|
|
- result.vultr_server.os == 'CentOS 6 x64'
|
|
|
|
- result.vultr_server.region == 'Amsterdam'
|
|
|
|
|
|
|
|
- name: test absent server idempotence
|
2018-08-13 10:21:50 +02:00
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
2018-01-21 22:54:12 +01:00
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
- name: verify test absent server idempotence
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result is not changed
|
2019-01-01 10:11:10 +01:00
|
|
|
|
|
|
|
- name: cleanup ssh keys
|
|
|
|
vultr_ssh_key:
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
ssh_key: "{{ item.key }}"
|
|
|
|
state: absent
|
|
|
|
loop: "{{ vultr_server_ssh_keys }}"
|