1
0
Fork 0
mirror of https://github.com/ansible-collections/hetzner.hcloud.git synced 2026-02-04 08:01:49 +00:00

Fix sanity tests

This commit is contained in:
Lukas Kämmerling 2020-06-24 09:23:39 +02:00
parent e1dba68a10
commit a2c4e403b8
2 changed files with 60 additions and 17 deletions

View file

@ -120,6 +120,61 @@ hcloud_network_info:
description: Servers attached to the network
returned: always
type: complex
id:
description: Numeric identifier of the server
returned: always
type: int
sample: 1937415
name:
description: Name of the server
returned: always
type: str
sample: my-server
status:
description: Status of the server
returned: always
type: str
sample: running
server_type:
description: Name of the server type of the server
returned: always
type: str
sample: cx11
ipv4_address:
description: Public IPv4 address of the server
returned: always
type: str
sample: 116.203.104.109
ipv6:
description: IPv6 network of the server
returned: always
type: str
sample: 2a01:4f8:1c1c:c140::/64
location:
description: Name of the location of the server
returned: always
type: str
sample: fsn1
datacenter:
description: Name of the datacenter of the server
returned: always
type: str
sample: fsn1-dc14
rescue_enabled:
description: True if rescue mode is enabled, Server will then boot into rescue system on next reboot
returned: always
type: bool
sample: false
backup_window:
description: Time window (UTC) in which the backup will run, or null if the backups are not enabled
returned: always
type: bool
sample: 22-02
labels:
description: User-defined labels (key-value pairs)
returned: always
type: dict
delete_protection:
description: True if the network is protected for deletion
returned: always

View file

@ -23,8 +23,6 @@ short_description: Gather infos about your Hetzner Cloud servers.
description:
- Gather infos about your Hetzner Cloud servers.
- This module was called C(hcloud_server_facts) before Ansible 2.9, returning C(ansible_facts) and C(hcloud_server_facts).
Note that the M(hcloud_server_info) module no longer returns C(ansible_facts) and the value was renamed to C(hcloud_server_info)!
author:
- Lukas Kaemmerling (@LKaemmerling)
@ -205,25 +203,15 @@ class AnsibleHcloudServerInfo(Hcloud):
def main():
module = AnsibleHcloudServerInfo.define_module()
is_old_facts = module._name == 'hcloud_server_facts'
if is_old_facts:
module.deprecate("The 'hcloud_server_facts' module has been renamed to 'hcloud_server_info', "
"and the renamed one no longer returns ansible_facts", version='2.0.0', collection_name="hetzner.hcloud")
hcloud = AnsibleHcloudServerInfo(module)
hcloud.get_servers()
result = hcloud.get_result()
if is_old_facts:
ansible_info = {
'hcloud_server_facts': result['hcloud_server_info']
}
module.exit_json(ansible_facts=ansible_info)
else:
ansible_info = {
'hcloud_server_info': result['hcloud_server_info']
}
module.exit_json(**ansible_info)
ansible_info = {
'hcloud_server_info': result['hcloud_server_info']
}
module.exit_json(**ansible_info)
if __name__ == "__main__":