Vultr: Introducing vultr_server_facts module (#43001)
This commit introduces a new module called vultr_server_facts.
This module aims to return the list of servers avaiable avaiable in
Vultr.
Sample available here:
```
"vultr_server_facts": [
{
"allowed_bandwidth_gb": 1000,
"application": null,
"auto_backup_enabled": false,
"cost_per_month": 5.00,
"current_bandwidth_gb": 0,
"date_created": "2018-07-19 08:23:03",
"default_password": "p4ssw0rd!",
"disk": "Virtual 25 GB",
"firewallgroup": null,
"id": 17241096,
"internal_ip": "",
"kvm_url": "https://my.vultr.com/subs/vps/novnc/api.php?data=OFB...",
"name": "ansibletest",
"os": "CentOS 7 x64",
"pending_charges": 0.01,
"plan": "1024 MB RAM,25 GB SSD,1.00 TB BW",
"power_status": "running",
"ram": "1024 MB",
"region": "Amsterdam",
"server_state": "ok",
"status": "active",
"tag": "",
"v4_gateway": "105.178.158.1",
"v4_main_ip": "105.178.158.181",
"v4_netmask": "255.255.254.0",
"v6_main_ip": "",
"v6_network": "",
"v6_network_size": "",
"v6_networks": [],
"vcpu_count": 1
}
]
2018-08-16 20:29:48 +02:00
|
|
|
# Copyright (c) 2018, Yanis Guenane <yanis+ansible@guenane.org>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
---
|
2018-11-04 11:23:36 +01:00
|
|
|
- name: setup ensure VM is absent
|
|
|
|
vultr_server:
|
|
|
|
name: "{{ vultr_server_name }}"
|
|
|
|
state: absent
|
|
|
|
register: result
|
|
|
|
|
|
|
|
# Servers can only be destroyed 5 min after creation
|
|
|
|
- name: wait for 5 min until VM is absent
|
|
|
|
local_action: wait_for
|
|
|
|
when: result is changed
|
|
|
|
|
Vultr: Introducing vultr_server_facts module (#43001)
This commit introduces a new module called vultr_server_facts.
This module aims to return the list of servers avaiable avaiable in
Vultr.
Sample available here:
```
"vultr_server_facts": [
{
"allowed_bandwidth_gb": 1000,
"application": null,
"auto_backup_enabled": false,
"cost_per_month": 5.00,
"current_bandwidth_gb": 0,
"date_created": "2018-07-19 08:23:03",
"default_password": "p4ssw0rd!",
"disk": "Virtual 25 GB",
"firewallgroup": null,
"id": 17241096,
"internal_ip": "",
"kvm_url": "https://my.vultr.com/subs/vps/novnc/api.php?data=OFB...",
"name": "ansibletest",
"os": "CentOS 7 x64",
"pending_charges": 0.01,
"plan": "1024 MB RAM,25 GB SSD,1.00 TB BW",
"power_status": "running",
"ram": "1024 MB",
"region": "Amsterdam",
"server_state": "ok",
"status": "active",
"tag": "",
"v4_gateway": "105.178.158.1",
"v4_main_ip": "105.178.158.181",
"v4_netmask": "255.255.254.0",
"v6_main_ip": "",
"v6_network": "",
"v6_network_size": "",
"v6_networks": [],
"vcpu_count": 1
}
]
2018-08-16 20:29:48 +02:00
|
|
|
- name: test gather vultr server facts - empty resources
|
|
|
|
vultr_server_facts:
|
2018-11-04 11:23:36 +01:00
|
|
|
- name: verify test gather vultr server facts - empty resources
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- ansible_facts.vultr_server_facts | count == 0
|
Vultr: Introducing vultr_server_facts module (#43001)
This commit introduces a new module called vultr_server_facts.
This module aims to return the list of servers avaiable avaiable in
Vultr.
Sample available here:
```
"vultr_server_facts": [
{
"allowed_bandwidth_gb": 1000,
"application": null,
"auto_backup_enabled": false,
"cost_per_month": 5.00,
"current_bandwidth_gb": 0,
"date_created": "2018-07-19 08:23:03",
"default_password": "p4ssw0rd!",
"disk": "Virtual 25 GB",
"firewallgroup": null,
"id": 17241096,
"internal_ip": "",
"kvm_url": "https://my.vultr.com/subs/vps/novnc/api.php?data=OFB...",
"name": "ansibletest",
"os": "CentOS 7 x64",
"pending_charges": 0.01,
"plan": "1024 MB RAM,25 GB SSD,1.00 TB BW",
"power_status": "running",
"ram": "1024 MB",
"region": "Amsterdam",
"server_state": "ok",
"status": "active",
"tag": "",
"v4_gateway": "105.178.158.1",
"v4_main_ip": "105.178.158.181",
"v4_netmask": "255.255.254.0",
"v6_main_ip": "",
"v6_network": "",
"v6_network_size": "",
"v6_networks": [],
"vcpu_count": 1
}
]
2018-08-16 20:29:48 +02:00
|
|
|
|
2018-11-09 14:06:34 +01:00
|
|
|
- name: setup firewall group
|
|
|
|
vultr_firewall_group:
|
|
|
|
name: test_vultr_server_facts
|
|
|
|
|
|
|
|
- name: setup create the server
|
Vultr: Introducing vultr_server_facts module (#43001)
This commit introduces a new module called vultr_server_facts.
This module aims to return the list of servers avaiable avaiable in
Vultr.
Sample available here:
```
"vultr_server_facts": [
{
"allowed_bandwidth_gb": 1000,
"application": null,
"auto_backup_enabled": false,
"cost_per_month": 5.00,
"current_bandwidth_gb": 0,
"date_created": "2018-07-19 08:23:03",
"default_password": "p4ssw0rd!",
"disk": "Virtual 25 GB",
"firewallgroup": null,
"id": 17241096,
"internal_ip": "",
"kvm_url": "https://my.vultr.com/subs/vps/novnc/api.php?data=OFB...",
"name": "ansibletest",
"os": "CentOS 7 x64",
"pending_charges": 0.01,
"plan": "1024 MB RAM,25 GB SSD,1.00 TB BW",
"power_status": "running",
"ram": "1024 MB",
"region": "Amsterdam",
"server_state": "ok",
"status": "active",
"tag": "",
"v4_gateway": "105.178.158.1",
"v4_main_ip": "105.178.158.181",
"v4_netmask": "255.255.254.0",
"v6_main_ip": "",
"v6_network": "",
"v6_network_size": "",
"v6_networks": [],
"vcpu_count": 1
}
]
2018-08-16 20:29:48 +02:00
|
|
|
vultr_server:
|
|
|
|
name: '{{ vultr_server_name }}'
|
|
|
|
os: '{{ vultr_server_os }}'
|
|
|
|
plan: '{{ vultr_server_plan }}'
|
|
|
|
region: '{{ vultr_server_region }}'
|
2018-11-09 14:06:34 +01:00
|
|
|
firewall_group: test_vultr_server_facts
|
Vultr: Introducing vultr_server_facts module (#43001)
This commit introduces a new module called vultr_server_facts.
This module aims to return the list of servers avaiable avaiable in
Vultr.
Sample available here:
```
"vultr_server_facts": [
{
"allowed_bandwidth_gb": 1000,
"application": null,
"auto_backup_enabled": false,
"cost_per_month": 5.00,
"current_bandwidth_gb": 0,
"date_created": "2018-07-19 08:23:03",
"default_password": "p4ssw0rd!",
"disk": "Virtual 25 GB",
"firewallgroup": null,
"id": 17241096,
"internal_ip": "",
"kvm_url": "https://my.vultr.com/subs/vps/novnc/api.php?data=OFB...",
"name": "ansibletest",
"os": "CentOS 7 x64",
"pending_charges": 0.01,
"plan": "1024 MB RAM,25 GB SSD,1.00 TB BW",
"power_status": "running",
"ram": "1024 MB",
"region": "Amsterdam",
"server_state": "ok",
"status": "active",
"tag": "",
"v4_gateway": "105.178.158.1",
"v4_main_ip": "105.178.158.181",
"v4_netmask": "255.255.254.0",
"v6_main_ip": "",
"v6_network": "",
"v6_network_size": "",
"v6_networks": [],
"vcpu_count": 1
}
]
2018-08-16 20:29:48 +02:00
|
|
|
|
|
|
|
- name: test gather vultr server facts in check mode
|
|
|
|
vultr_server_facts:
|
|
|
|
check_mode: yes
|
|
|
|
|
|
|
|
- name: verify test gather vultr server facts in check mode
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- ansible_facts.vultr_server_facts|selectattr('name','equalto','{{ vultr_server_name }}') | list | count == 1
|
|
|
|
|
|
|
|
- name: test gather vultr server facts
|
|
|
|
vultr_server_facts:
|
|
|
|
|
|
|
|
- name: verify test gather vultr server facts
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- ansible_facts.vultr_server_facts|selectattr('name','equalto','{{ vultr_server_name }}') | list | count == 1
|
|
|
|
|
|
|
|
- name: Pause for 5 min before deleting the VM
|
|
|
|
pause:
|
|
|
|
minutes: 5
|
|
|
|
|
2018-11-09 14:06:34 +01:00
|
|
|
- name: cleanup the server
|
Vultr: Introducing vultr_server_facts module (#43001)
This commit introduces a new module called vultr_server_facts.
This module aims to return the list of servers avaiable avaiable in
Vultr.
Sample available here:
```
"vultr_server_facts": [
{
"allowed_bandwidth_gb": 1000,
"application": null,
"auto_backup_enabled": false,
"cost_per_month": 5.00,
"current_bandwidth_gb": 0,
"date_created": "2018-07-19 08:23:03",
"default_password": "p4ssw0rd!",
"disk": "Virtual 25 GB",
"firewallgroup": null,
"id": 17241096,
"internal_ip": "",
"kvm_url": "https://my.vultr.com/subs/vps/novnc/api.php?data=OFB...",
"name": "ansibletest",
"os": "CentOS 7 x64",
"pending_charges": 0.01,
"plan": "1024 MB RAM,25 GB SSD,1.00 TB BW",
"power_status": "running",
"ram": "1024 MB",
"region": "Amsterdam",
"server_state": "ok",
"status": "active",
"tag": "",
"v4_gateway": "105.178.158.1",
"v4_main_ip": "105.178.158.181",
"v4_netmask": "255.255.254.0",
"v6_main_ip": "",
"v6_network": "",
"v6_network_size": "",
"v6_networks": [],
"vcpu_count": 1
}
]
2018-08-16 20:29:48 +02:00
|
|
|
vultr_server:
|
|
|
|
name: '{{ vultr_server_name }}'
|
|
|
|
state: absent
|
2018-11-09 14:06:34 +01:00
|
|
|
|
|
|
|
- name: cleanup firewall group
|
|
|
|
vultr_firewall_group:
|
|
|
|
name: test_vultr_server_facts
|
|
|
|
state: absent
|