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
}
]
6 years ago
|
|
|
# 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)
|
|
|
|
---
|
|
|
|
- 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
|
|
|
|
wait_for:
|
|
|
|
when: result is changed
|
|
|
|
|
|
|
|
- name: test gather vultr server info - empty resources
|
|
|
|
vultr_server_info:
|
|
|
|
register: result
|
|
|
|
- name: verify test gather vultr server info - empty resources
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result.vultr_server_info | selectattr('name','equalto',vultr_server_name) | list | 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
}
]
6 years ago
|
|
|
|
|
|
|
- name: setup firewall group
|
|
|
|
vultr_firewall_group:
|
|
|
|
name: test_vultr_server_info
|
|
|
|
|
|
|
|
- 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
}
]
6 years ago
|
|
|
vultr_server:
|
|
|
|
name: '{{ vultr_server_name }}'
|
|
|
|
os: '{{ vultr_server_os }}'
|
|
|
|
plan: '{{ vultr_server_plan }}'
|
|
|
|
region: '{{ vultr_server_region }}'
|
|
|
|
firewall_group: test_vultr_server_info
|
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
}
]
6 years ago
|
|
|
|
|
|
|
- name: test gather vultr server info in check mode
|
|
|
|
vultr_server_info:
|
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
}
]
6 years ago
|
|
|
check_mode: yes
|
|
|
|
register: result
|
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
}
]
6 years ago
|
|
|
|
|
|
|
- name: verify test gather vultr server info in check mode
|
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
}
]
6 years ago
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result.vultr_server_info|selectattr('name','equalto',vultr_server_name) | list | count == 1
|
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
}
]
6 years ago
|
|
|
|
|
|
|
- name: test gather vultr server info
|
|
|
|
vultr_server_info:
|
|
|
|
register: result
|
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
}
]
6 years ago
|
|
|
|
|
|
|
- name: verify test gather vultr server info
|
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
}
]
6 years ago
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- result.vultr_server_info|selectattr('name','equalto',vultr_server_name) | list | count == 1
|
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
}
]
6 years ago
|
|
|
|
|
|
|
- name: Pause for 5 min before deleting the VM
|
|
|
|
pause:
|
|
|
|
minutes: 5
|
|
|
|
|
|
|
|
- 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
}
]
6 years ago
|
|
|
vultr_server:
|
|
|
|
name: '{{ vultr_server_name }}'
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: cleanup firewall group
|
|
|
|
vultr_firewall_group:
|
|
|
|
name: test_vultr_server_info
|
|
|
|
state: absent
|