mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 14:41:23 -07:00
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 } ]
This commit is contained in:
parent
c84e70cf10
commit
2556098479
5 changed files with 265 additions and 0 deletions
|
@ -251,6 +251,9 @@ class Vultr:
|
|||
elif config['convert_to'] == 'bool':
|
||||
resource[search_key] = True if resource[search_key] == 'yes' else False
|
||||
|
||||
if 'transform' in config:
|
||||
resource[search_key] = config['transform'](resource[search_key])
|
||||
|
||||
if 'key' in config:
|
||||
resource[config['key']] = resource[search_key]
|
||||
del resource[search_key]
|
||||
|
@ -265,3 +268,34 @@ class Vultr:
|
|||
self.result[self.namespace] = self.normalize_result(resource)
|
||||
|
||||
return self.result
|
||||
|
||||
def get_plan(self, plan=None, key='name'):
|
||||
value = plan or self.module.params.get('plan')
|
||||
|
||||
return self.query_resource_by_key(
|
||||
key=key,
|
||||
value=value,
|
||||
resource='plans',
|
||||
use_cache=True
|
||||
)
|
||||
|
||||
def get_firewallgroup(self, firewallgroup=None, key='description'):
|
||||
value = firewallgroup or self.module.params.get('firewallgroup')
|
||||
|
||||
return self.query_resource_by_key(
|
||||
key=key,
|
||||
value=value,
|
||||
resource='firewall',
|
||||
query_by='group_list',
|
||||
use_cache=True
|
||||
)
|
||||
|
||||
def get_application(self, application=None, key='name'):
|
||||
value = application or self.module.params.get('application')
|
||||
|
||||
return self.query_resource_by_key(
|
||||
key=key,
|
||||
value=value,
|
||||
resource='app',
|
||||
use_cache=True
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue