Vultr: Introducing vultr_network_facts module (#43600)

This commit introduces a new module called vultr_network_facts.

This module aims to return the list of networks avaiable in Vultr.

Sample available here:

```
"vultr_network_facts": [
  {
    "date_created": "2018-08-02 11:18:49",
    "id": "net5b62e8991adfg",
    "name": "mynet",
    "region": "Amsterdam",
    "v4_subnet": "192.168.42.0",
    "v4_subnet_mask": 24
  }
]
```
This commit is contained in:
Yanis Guenane 2018-08-20 00:29:05 +02:00 committed by René Moser
commit 0c65bcb23b
4 changed files with 172 additions and 0 deletions

View file

@ -0,0 +1,3 @@
vultr_network_name: mytestnetwork
vultr_network_cidr: 192.168.42.0/24
vultr_network_region: New Jersey

View file

@ -0,0 +1,33 @@
# 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 network facts - empty resources
vultr_network_facts:
- name: Create the network
vultr_network:
name: '{{ vultr_network_name }}'
cidr: '{{ vultr_network_cidr }}'
region: '{{ vultr_network_region }}'
- name: test gather vultr network facts in check mode
vultr_network_facts:
check_mode: yes
- name: verify test gather vultr network facts in check mode
assert:
that:
- ansible_facts.vultr_network_facts|selectattr('name','equalto','{{ vultr_network_name }}') | list | count == 1
- name: test gather vultr network facts
vultr_network_facts:
- name: verify test gather vultr network facts
assert:
that:
- ansible_facts.vultr_network_facts|selectattr('name','equalto','{{ vultr_network_name }}') | list | count == 1
- name: Delete the script
vultr_network:
name: '{{ vultr_network_name }}'
state: absent

View file

@ -15,6 +15,7 @@
- { role: vultr_firewall_group_facts, tags: test_vultr_firewall_group_facts }
- { role: vultr_firewall_rule, tags: test_vultr_firewall_rule }
- { role: vultr_network, tags: test_vultr_network }
- { role: vultr_network_facts, tags: test_vultr_network_facts }
- { role: vultr_os_facts, tags: test_vultr_os_facts }
- { role: vultr_plan_facts, tags: test_vultr_plan_facts }
- { role: vultr_region_facts, tags: test_vultr_region_facts }