Add tls cert
This commit is contained in:
parent
7323cbdd72
commit
4654fbeaac
@ -39,24 +39,27 @@ class ActionModule(ActionBase):
|
||||
module_args = self._task.args.copy()
|
||||
|
||||
if not "dir" in module_args:
|
||||
raise AnsibleError('\'dir\' option is mendatory in load_haproxy_config')
|
||||
raise AnsibleError('\'dir\' option is mendatory in load_hasites_config')
|
||||
if not "default_domain" in module_args:
|
||||
raise AnsibleError('\'default_domain\' option is mendatory in load_haproxy_config')
|
||||
raise AnsibleError('\'default_domain\' option is mendatory in load_hasites_config')
|
||||
if not "default_dns_provider" in module_args:
|
||||
raise AnsibleError('\'default_dns_provider\' option is mendatory in load_haproxy_config')
|
||||
raise AnsibleError('\'default_dns_provider\' option is mendatory in load_hasites_config')
|
||||
if not "default_dns_target" in module_args:
|
||||
raise AnsibleError('\'default_dns_target\' option is mendatory in load_haproxy_config')
|
||||
raise AnsibleError('\'default_dns_target\' option is mendatory in load_hasites_config')
|
||||
if not "default_tls_cert_dir" in module_args:
|
||||
raise AnsibleError('\'default_tls_cert_dir\' option is mendatory in load_hasites_config')
|
||||
|
||||
self.source_dir = module_args.get('dir')
|
||||
self.default_domain = module_args.get('default_domain')
|
||||
self.default_dns_provider = module_args.get('default_dns_provider')
|
||||
self.default_dns_target = module_args.get('default_dns_target')
|
||||
self.default_tls_cert_dir = module_args.get('default_tls_cert_dir')
|
||||
self.dir = module_args.get('dir')
|
||||
self.depth = module_args.get('depth', 0)
|
||||
|
||||
results = {
|
||||
"dns_hostnames": dict(), # { provider: [ { hostname:"", domain:"", state: "", target: "" } ] }
|
||||
"proxy_config": [],
|
||||
"sites_config": [],
|
||||
"uptime_config": [] # [{ name:"", url: "", protected: True, state: "" }]
|
||||
}
|
||||
failed = False
|
||||
@ -73,7 +76,7 @@ class ActionModule(ActionBase):
|
||||
failed, err_msg, updated_results = (self._load_files_in_dir(root_dir, filenames))
|
||||
if failed:
|
||||
break
|
||||
results['proxy_config'] = results['proxy_config'] + updated_results['proxy_config']
|
||||
results['sites_config'] = results['sites_config'] + updated_results['sites_config']
|
||||
for key, value in updated_results['dns_hostnames'].items():
|
||||
results['dns_hostnames'][key] = results['dns_hostnames'].get(key, []) + value
|
||||
results['uptime_config'] = results['uptime_config'] + updated_results['uptime_config']
|
||||
@ -85,7 +88,7 @@ class ActionModule(ActionBase):
|
||||
result['failed'] = failed
|
||||
result['message'] = err_msg
|
||||
scope = dict()
|
||||
scope['haproxy_config'] = results
|
||||
scope['caddy_config'] = results
|
||||
results = scope
|
||||
result['ansible_included_var_files'] = self.included_files
|
||||
result['ansible_facts'] = results
|
||||
@ -176,7 +179,7 @@ class ActionModule(ActionBase):
|
||||
"""
|
||||
results = {
|
||||
"dns_hostnames": dict(), # { provider: [ { hostname:"", domain:"", state: "", target: "" } ] }
|
||||
"proxy_config": [], # {site: "xx.fr", upstream: "", upstream_config: [], protected: true, whitelist_local: true, domain: ""}
|
||||
"sites_config": [], # {site: "xx.fr", upstream: "", upstream_config: [], protected: true, whitelist_local: true, domain: "", tls_cert_dir: ""}
|
||||
"uptime_config": [] # [{ name:"", url: "", protected: True, state: "" }]
|
||||
}
|
||||
failed = False
|
||||
@ -202,6 +205,7 @@ class ActionModule(ActionBase):
|
||||
dns_target = dns.get("target", self.default_dns_target)
|
||||
protected = loaded_data.get("protected", False)
|
||||
whitelist_local = loaded_data.get("whitelist_local", False)
|
||||
tls_cert_dir = loaded_data.get("tls_cert_dir", self.default_tls_cert_dir)
|
||||
additionnal_hostname = loaded_data.get('additionnal_hostname', [])
|
||||
state = loaded_data.get("state", "present")
|
||||
uptime_raw_config = loaded_data.get("uptime", dict())
|
||||
@ -214,12 +218,13 @@ class ActionModule(ActionBase):
|
||||
upstream_config = loaded_data.get("upstream_config")
|
||||
|
||||
if state == "present":
|
||||
results['proxy_config'].append({
|
||||
results['sites_config'].append({
|
||||
"site": '{0}.{1}'.format(main_hostname, domain),
|
||||
"upstream": upstream,
|
||||
"upstream_config": upstream_config,
|
||||
"protected": protected,
|
||||
"whitelist_local": whitelist_local,
|
||||
"tls_cert_dir": tls_cert_dir,
|
||||
"health_uri": "/" + uptime_raw_config.get("endpoint", "")
|
||||
})
|
||||
|
||||
@ -248,7 +253,8 @@ class ActionModule(ActionBase):
|
||||
this_dns_provider = this_dns.get("provider", dns_provider)
|
||||
this_dns_target = this_dns.get("target", dns_target)
|
||||
this_protected = host.get('protected', protected)
|
||||
this_whitelist_local = loaded_data.get("whitelist_local", whitelist_local)
|
||||
this_tls_cert_dir = host.get("tls_cert_dir", self.default_tls_cert_dir)
|
||||
this_whitelist_local = host.get("whitelist_local", whitelist_local)
|
||||
this_state = host.get('state', state)
|
||||
this_uptime_raw_config = host.get("uptime", dict())
|
||||
full_domain = '{0}.{1}'.format(host.get("hostname"), this_domain) if host.get("hostname") else this_domain
|
||||
@ -256,10 +262,11 @@ class ActionModule(ActionBase):
|
||||
this_upstream_config = host.get("upstream_config")
|
||||
|
||||
if this_state == "present":
|
||||
results['proxy_config'].append({
|
||||
results['sites_config'].append({
|
||||
"site": full_domain,
|
||||
"upstream": upstream,
|
||||
"upstream_config": this_upstream_config,
|
||||
"tls_cert_dir": this_tls_cert_dir,
|
||||
"protected": this_protected,
|
||||
"whitelist_local": this_whitelist_local,
|
||||
"health_uri": "/" + this_uptime_raw_config.get("endpoint", "")
|
||||
|
Loading…
Reference in New Issue
Block a user