Load uptime config
This commit is contained in:
parent
a0a47ae4c2
commit
7d49ce1ce3
@ -58,7 +58,8 @@ class ActionModule(ActionBase):
|
|||||||
"domain_maping": [],
|
"domain_maping": [],
|
||||||
"dns_hostnames": dict(), # { provider: [ { hostname:"", domain:"", state: "", target: "" } ] }
|
"dns_hostnames": dict(), # { provider: [ { hostname:"", domain:"", state: "", target: "" } ] }
|
||||||
"protected_domain": [],
|
"protected_domain": [],
|
||||||
"backend_config": []
|
"backend_config": [],
|
||||||
|
"uptime_config": [] # [{ name:"", url: "", protected: True, state: "" }]
|
||||||
}
|
}
|
||||||
failed = False
|
failed = False
|
||||||
|
|
||||||
@ -79,6 +80,7 @@ class ActionModule(ActionBase):
|
|||||||
results['backend_config'] = results['backend_config'] + updated_results['backend_config']
|
results['backend_config'] = results['backend_config'] + updated_results['backend_config']
|
||||||
for key, value in updated_results['dns_hostnames'].items():
|
for key, value in updated_results['dns_hostnames'].items():
|
||||||
results['dns_hostnames'][key] = results['dns_hostnames'].get(key, []) + value
|
results['dns_hostnames'][key] = results['dns_hostnames'].get(key, []) + value
|
||||||
|
results['uptime_config'] = results['uptime_config'] + updated_results['uptime_config']
|
||||||
|
|
||||||
|
|
||||||
result = super(ActionModule, self).run(task_vars=task_vars)
|
result = super(ActionModule, self).run(task_vars=task_vars)
|
||||||
@ -180,7 +182,8 @@ class ActionModule(ActionBase):
|
|||||||
"domain_maping": [],
|
"domain_maping": [],
|
||||||
"dns_hostnames": dict(), # { provider: [ { hostname:"", domain:"", state: "", target: "" } ] }
|
"dns_hostnames": dict(), # { provider: [ { hostname:"", domain:"", state: "", target: "" } ] }
|
||||||
"protected_domain": [],
|
"protected_domain": [],
|
||||||
"backend_config": []
|
"backend_config": [],
|
||||||
|
"uptime_config": [] # [{ name:"", url: "", protected: True, state: "" }]
|
||||||
}
|
}
|
||||||
failed = False
|
failed = False
|
||||||
err_msg = ''
|
err_msg = ''
|
||||||
@ -205,6 +208,8 @@ class ActionModule(ActionBase):
|
|||||||
protected = loaded_data.get("protected", False)
|
protected = loaded_data.get("protected", False)
|
||||||
additionnal_hostname = loaded_data.get('additionnal_hostname', [])
|
additionnal_hostname = loaded_data.get('additionnal_hostname', [])
|
||||||
state = loaded_data.get("state", "present")
|
state = loaded_data.get("state", "present")
|
||||||
|
uptime_raw_config = loaded_data.get("uptime", dict())
|
||||||
|
|
||||||
if "backend" not in loaded_data:
|
if "backend" not in loaded_data:
|
||||||
failed = True
|
failed = True
|
||||||
err_msg = ('Could not find "backend" in {0}'.format(to_native(filename)))
|
err_msg = ('Could not find "backend" in {0}'.format(to_native(filename)))
|
||||||
@ -216,7 +221,7 @@ class ActionModule(ActionBase):
|
|||||||
results['backend_config'].append(backend)
|
results['backend_config'].append(backend)
|
||||||
if protected:
|
if protected:
|
||||||
results['protected_domain'].append('{0}.{1}'.format(main_hostname, domain))
|
results['protected_domain'].append('{0}.{1}'.format(main_hostname, domain))
|
||||||
|
|
||||||
if not dns.get("skip", False):
|
if not dns.get("skip", False):
|
||||||
if not dns_provider in results['dns_hostnames']:
|
if not dns_provider in results['dns_hostnames']:
|
||||||
results['dns_hostnames'].update({ dns_provider: []})
|
results['dns_hostnames'].update({ dns_provider: []})
|
||||||
@ -227,7 +232,15 @@ class ActionModule(ActionBase):
|
|||||||
"target": dns_target,
|
"target": dns_target,
|
||||||
"state": state,
|
"state": state,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
results['uptime_config'].append({
|
||||||
|
"name": main_hostname,
|
||||||
|
"url": 'https://{0}.{1}/{2}'.format(main_hostname, domain, uptime_raw_config.get("endpoint", "")),
|
||||||
|
"protected": protected,
|
||||||
|
"state": uptime_raw_config.get("state", state)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
for host in additionnal_hostname:
|
for host in additionnal_hostname:
|
||||||
this_dns = host.get("dns", dns)
|
this_dns = host.get("dns", dns)
|
||||||
this_domain = this_dns.get("domain", domain)
|
this_domain = this_dns.get("domain", domain)
|
||||||
@ -235,6 +248,7 @@ class ActionModule(ActionBase):
|
|||||||
this_dns_target = this_dns.get("target", dns_target)
|
this_dns_target = this_dns.get("target", dns_target)
|
||||||
this_protected = host.get('protected', protected)
|
this_protected = host.get('protected', protected)
|
||||||
this_state = host.get('state', state)
|
this_state = host.get('state', state)
|
||||||
|
this_uptime_raw_config = host.get("uptime", dict())
|
||||||
|
|
||||||
if this_state == "present":
|
if this_state == "present":
|
||||||
full_domain = '{0}.{1}'.format(host.get("hostname"), this_domain) if host.get("hostname") else this_domain
|
full_domain = '{0}.{1}'.format(host.get("hostname"), this_domain) if host.get("hostname") else this_domain
|
||||||
@ -252,4 +266,10 @@ class ActionModule(ActionBase):
|
|||||||
"target": this_dns_target,
|
"target": this_dns_target,
|
||||||
"state": this_state
|
"state": this_state
|
||||||
})
|
})
|
||||||
|
results['uptime_config'].append({
|
||||||
|
"name": host.get("hostname"),
|
||||||
|
"url": 'https://{0}/{1}'.format(full_domain, this_uptime_raw_config.get("endpoint", "")),
|
||||||
|
"protected": this_protected,
|
||||||
|
"state": this_uptime_raw_config.get("state", this_state)
|
||||||
|
})
|
||||||
return failed, err_msg, results
|
return failed, err_msg, results
|
Loading…
Reference in New Issue
Block a user