mirror of
https://github.com/ansible-collections/hetzner.hcloud
synced 2024-11-10 06:34:13 +00:00
feat: target health status in hcloud_load_balancer_info (#305)
This commit is contained in:
parent
7d2300f1ec
commit
5475a9929a
3 changed files with 31 additions and 0 deletions
|
@ -0,0 +1,2 @@
|
|||
minor_changes:
|
||||
- hcloud_load_balancer_info - Add targets health status field.
|
|
@ -138,6 +138,23 @@ hcloud_load_balancer_info:
|
|||
type: bool
|
||||
sample: true
|
||||
returned: always
|
||||
health_status:
|
||||
description:
|
||||
- List of health statuses of the services on this target. Only present for target types "server" and "ip".
|
||||
type: list
|
||||
returned: if I(type) is server or ip
|
||||
contains:
|
||||
listen_port:
|
||||
description: Load Balancer Target listen port
|
||||
type: int
|
||||
returned: always
|
||||
sample: 80
|
||||
status:
|
||||
description: Load Balancer Target status
|
||||
type: str
|
||||
choices: [healthy, unhealthy, unknown]
|
||||
returned: always
|
||||
sample: healthy
|
||||
services:
|
||||
description: all services from this Load Balancer
|
||||
returned: Always
|
||||
|
@ -345,6 +362,16 @@ class AnsibleHCloudLoadBalancerInfo(AnsibleHCloud):
|
|||
result["label_selector"] = to_native(target.label_selector.selector)
|
||||
elif target.type == "ip":
|
||||
result["ip"] = to_native(target.ip.ip)
|
||||
|
||||
if target.health_status is not None:
|
||||
result["health_status"] = [
|
||||
{
|
||||
"listen_port": item.listen_port,
|
||||
"status": item.status,
|
||||
}
|
||||
for item in target.health_status
|
||||
]
|
||||
|
||||
return result
|
||||
|
||||
def get_load_balancers(self):
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
- result.hcloud_load_balancer_info[0].targets | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].targets | selectattr('type', 'equalto', 'server') | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].targets | selectattr('server', 'equalto', '{{ hcloud_server_name }}') | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].targets[0].health_status[0].listen_port == 80
|
||||
- result.hcloud_load_balancer_info[0].targets[0].health_status[0].status in ['healthy', 'unhealthy', 'unknown']
|
||||
- result.hcloud_load_balancer_info[0].services | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].services | selectattr('protocol', 'equalto', 'http') | list | count == 1
|
||||
- result.hcloud_load_balancer_info[0].services | selectattr('listen_port', 'equalto', 80) | list | count == 1
|
||||
|
|
Loading…
Reference in a new issue