generalized the systemdbool function
Dieser Commit ist enthalten in:
Ursprung
e2dea89599
Commit
76f4e64081
|
@ -6,6 +6,7 @@ __all__ = (
|
||||||
"SYSTEMD_SERVICE_CONFIG",
|
"SYSTEMD_SERVICE_CONFIG",
|
||||||
"SYSTEMD_NETWORK_CONFIG",
|
"SYSTEMD_NETWORK_CONFIG",
|
||||||
"SYSTEMD_CONFIG_ROOT",
|
"SYSTEMD_CONFIG_ROOT",
|
||||||
|
"systemdbool",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -126,3 +127,11 @@ class Types(metaclass=_Type):
|
||||||
argument.__name__ = name
|
argument.__name__ = name
|
||||||
argument.__doc__ = argument.__doc__.format(name)
|
argument.__doc__ = argument.__doc__.format(name)
|
||||||
return argument
|
return argument
|
||||||
|
|
||||||
|
|
||||||
|
def systemdbool(b: Union[bool, str]) -> str:
|
||||||
|
if b is True:
|
||||||
|
return "yes"
|
||||||
|
elif b is False:
|
||||||
|
return "no"
|
||||||
|
return b
|
||||||
|
|
|
@ -4,20 +4,12 @@ from typing import List, Union
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule
|
from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule, systemdbool
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types, systemdbool
|
||||||
from plugins.module_utils.module import SystemdUnitModule
|
from plugins.module_utils.module import SystemdUnitModule
|
||||||
|
|
||||||
|
|
||||||
def boolconvert(b: Union[bool, str]) -> str:
|
|
||||||
if b is True:
|
|
||||||
return "yes"
|
|
||||||
elif b is False:
|
|
||||||
return "no"
|
|
||||||
return b
|
|
||||||
|
|
||||||
|
|
||||||
class Module(SystemdUnitModule):
|
class Module(SystemdUnitModule):
|
||||||
"""Sets up the systemd network unit"""
|
"""Sets up the systemd network unit"""
|
||||||
|
|
||||||
|
@ -87,8 +79,8 @@ class Module(SystemdUnitModule):
|
||||||
domain = self.get("domain")
|
domain = self.get("domain")
|
||||||
self.set("domainlog", str(domain))
|
self.set("domainlog", str(domain))
|
||||||
options.append("Domains={}".format(" ".join(domain)))
|
options.append("Domains={}".format(" ".join(domain)))
|
||||||
options.append("DNSOverTLS={}".format(boolconvert(self.get("dot", "opportunistic"))))
|
options.append("DNSOverTLS={}".format(systemdbool(self.get("dot", "opportunistic"))))
|
||||||
options.append("DNSSEC={}".format(boolconvert(self.get("dnssec", "allow-downgrade"))))
|
options.append("DNSSEC={}".format(systemdbool(self.get("dnssec", "allow-downgrade"))))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
output += "\n".join(options)
|
output += "\n".join(options)
|
||||||
|
|
Laden…
In neuem Issue referenzieren