diff --git a/hosts.yml b/hosts.yml index 8897ec70241e055234d7055d8d05e0fa43be28b4..f640eb0692422e89c851174c88c22f22bfcb4eec 100644 --- a/hosts.yml +++ b/hosts.yml @@ -15,7 +15,6 @@ hosts: ip: 37.218.242.216 ip_vpn0: 172.16.1.3 gateway_address: 37.218.242.191 - gateway_address6: 2001:db8:123::1 location: Amsterdam gateway2: ansible_host: 204.13.164.252 diff --git a/plugins/action/simplevpn.py b/plugins/action/simplevpn.py index 0b44bee5a96897c9e6f90e8dd7f5334b9846e8d4..850043d3a36deff25dbf592f475eb8cd6be9fe14 100644 --- a/plugins/action/simplevpn.py +++ b/plugins/action/simplevpn.py @@ -27,6 +27,17 @@ def patchObfs4Cert(transports, cert): return transports +def no_nulls(d): + if isinstance(d, dict): + return dict( + (k, no_nulls(v)) + for k, v in d.items() if v is not None) + elif isinstance(d, list): + return [no_nulls(x) for x in d if x] + else: + return d + + def produceEipConfig(config, obfs4_state_dir, public_domain, transports): if obfs4_state_dir: obfs4_cert = open( @@ -52,11 +63,11 @@ def produceEipConfig(config, obfs4_state_dir, public_domain, transports): } for v in config.gateways], "openvpn_configuration": config.openvpn, } - + # Instead of calling the template here, we just return the # 'config' object so that Ansible can use it with its own template # module. - return eip_config + return no_nulls(eip_config) def produceProviderConfig(public_domain, provider_api_uri, ca_cert_uri, ca_public_crt): @@ -104,7 +115,7 @@ def produceProviderConfig(public_domain, provider_api_uri, ca_cert_uri, ca_publi # Instead of calling the template here, we just return the # 'config' object so that Ansible can use it with its own template # module. - return provider_config + return no_nulls(provider_config) class ActionModule(ActionBase):