ansible/test/legacy/roles/vultr_server_facts/tasks/main.yml
Yanis Guenane 2556098479 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

38 lines
1.1 KiB
YAML

# 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: test gather vultr server facts - empty resources
vultr_server_facts:
- name: Create the server
vultr_server:
name: '{{ vultr_server_name }}'
os: '{{ vultr_server_os }}'
plan: '{{ vultr_server_plan }}'
region: '{{ vultr_server_region }}'
- 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
- name: Delete the server
vultr_server:
name: '{{ vultr_server_name }}'
state: absent