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

Fix inventory plugin does not work with old configuration files (#15)

This commit is contained in:
Lukas Kämmerling 2020-06-30 13:48:24 +02:00 committed by GitHub
parent d795d331e7
commit 41354355e6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 9 deletions

View file

@ -230,7 +230,7 @@ class InventoryModule(BaseInventoryPlugin, Constructable):
"""Return the possibly of a file being consumable by this plugin."""
return (
super(InventoryModule, self).verify_file(path) and
path.endswith((self.NAME + ".yaml", self.NAME + ".yml"))
path.endswith(("hcloud.yaml", "hcloud.yml"))
)
def parse(self, inventory, loader, path, cache=True):

View file

@ -174,7 +174,7 @@ class AnsibleHcloudLoadBalancer(Hcloud):
"location": to_native(self.hcloud_load_balancer.location.name),
"labels": self.hcloud_load_balancer.labels,
"delete_protection": self.hcloud_load_balancer.protection["delete"],
"disable_public_interface": self.hcloud_load_balancer.public_net.enabled
"disable_public_interface": False if self.hcloud_load_balancer.public_net.enabled else True,
}
def _get_load_balancer(self):
@ -219,7 +219,6 @@ class AnsibleHcloudLoadBalancer(Hcloud):
self._mark_as_changed()
self._get_load_balancer()
self._update_load_balancer()
def _update_load_balancer(self):
try:
@ -237,7 +236,7 @@ class AnsibleHcloudLoadBalancer(Hcloud):
self._get_load_balancer()
disable_public_interface = self.module.params.get("disable_public_interface")
if disable_public_interface is not None and disable_public_interface != self.hcloud_load_balancer.public_net.enabled:
if disable_public_interface is not None and disable_public_interface != (not self.hcloud_load_balancer.public_net.enabled):
if not self.module.check_mode:
if disable_public_interface is True:
self.hcloud_load_balancer.disable_public_interface().wait_until_finished()
@ -277,7 +276,7 @@ class AnsibleHcloudLoadBalancer(Hcloud):
network_zone={"type": "str"},
labels={"type": "dict"},
delete_protection={"type": "bool"},
disable_public_interface={"type": "bool", "default": False},
disable_public_interface={"type": "bool"},
state={
"choices": ["absent", "present"],
"default": "present",

View file

@ -322,7 +322,7 @@ class AnsibleHcloudLoadBalancerService(Hcloud):
"response": to_native(self.hcloud_load_balancer_service.health_check.http.response),
"certificates": [to_native(status_code) for status_code in
self.hcloud_load_balancer_service.health_check.http.status_codes],
"tls": self.hcloud_load_balancer_service.health_check.tls,
"tls": self.hcloud_load_balancer_service.health_check.http.tls,
}
return {
"load_balancer": to_native(self.hcloud_load_balancer.name),