updated formatting
Dieser Commit ist enthalten in:
Ursprung
53057c18a2
Commit
52b5a96926
|
@ -3,10 +3,8 @@ import pathlib
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import (
|
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||||
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
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||||
from plugins.module_utils.module import SystemdUnitModule
|
from plugins.module_utils.module import SystemdUnitModule
|
||||||
|
@ -19,21 +17,11 @@ class Module(SystemdUnitModule):
|
||||||
module_spec = dict(
|
module_spec = dict(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
mac=Types.str(help="The Mac address of the device"),
|
mac=Types.str(help="The Mac address of the device"),
|
||||||
permanentmac=Types.str(
|
permanentmac=Types.str(help="The Permanent Mac address advertised by the device"),
|
||||||
help="The Permanent Mac address advertised by the device"
|
path=Types.str(help="A shell-style glob matching the persistent path, as exposed by the udev property ID_PATH."),
|
||||||
),
|
driver=Types.str(help="A glob matching the driver currently bound to the device"),
|
||||||
path=Types.str(
|
type=Types.str(help="A glob matching the device type, as exposed by networkctl list"),
|
||||||
help="A shell-style glob matching the persistent path, as exposed by the udev property ID_PATH."
|
kind=Types.str(help="a glob matching the device kind, as exposed by networkctl status INTERFACE or ip -d link show INTERFACE."),
|
||||||
),
|
|
||||||
driver=Types.str(
|
|
||||||
help="A glob matching the driver currently bound to the device"
|
|
||||||
),
|
|
||||||
type=Types.str(
|
|
||||||
help="A glob matching the device type, as exposed by networkctl list"
|
|
||||||
),
|
|
||||||
kind=Types.str(
|
|
||||||
help="a glob matching the device kind, as exposed by networkctl status INTERFACE or ip -d link show INTERFACE."
|
|
||||||
),
|
|
||||||
description=Types.str(help="The description for the link"),
|
description=Types.str(help="The description for the link"),
|
||||||
name=Types.str(required=True, help="The new name of the device"),
|
name=Types.str(required=True, help="The new name of the device"),
|
||||||
mtu=Types.int(help="The maximum Transmission unit for the link"),
|
mtu=Types.int(help="The maximum Transmission unit for the link"),
|
||||||
|
@ -46,13 +34,9 @@ class Module(SystemdUnitModule):
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
self.__unit = None
|
self.__unit = None
|
||||||
newname = (
|
newname = self.get("name", "") or self.get("mac", "") or self.get("permanentmac", "")
|
||||||
self.get("name", "") or self.get("mac", "") or self.get("permanentmac", "")
|
|
||||||
)
|
|
||||||
newname = newname.replace(":", "").replace("/", "-").lower()
|
newname = newname.replace(":", "").replace("/", "-").lower()
|
||||||
self.unitfile = SYSTEMD_NETWORK_CONFIG.joinpath("50-" + newname).with_suffix(
|
self.unitfile = SYSTEMD_NETWORK_CONFIG.joinpath("50-" + newname).with_suffix(".link")
|
||||||
".link"
|
|
||||||
)
|
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
if self.__unit is None:
|
if self.__unit is None:
|
||||||
|
@ -64,9 +48,7 @@ class Module(SystemdUnitModule):
|
||||||
if self.get("mac", False):
|
if self.get("mac", False):
|
||||||
options.append("MACAddress={}\n".format(self.get("mac", False)))
|
options.append("MACAddress={}\n".format(self.get("mac", False)))
|
||||||
if self.get("permanentmac", False):
|
if self.get("permanentmac", False):
|
||||||
options.append(
|
options.append("PermanentAddress={}\n".format(self.get("permanentmac", False)))
|
||||||
"PermanentAddress={}\n".format(self.get("permanentmac", False))
|
|
||||||
)
|
|
||||||
if self.get("path", False):
|
if self.get("path", False):
|
||||||
options.append("Path={}\n".format(self.get("path", False)))
|
options.append("Path={}\n".format(self.get("path", False)))
|
||||||
if self.get("driver", False):
|
if self.get("driver", False):
|
||||||
|
|
|
@ -3,10 +3,8 @@ import pathlib
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import (
|
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types
|
||||||
SYSTEMD_SERVICE_CONFIG, Types)
|
from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.module import \
|
|
||||||
SystemdUnitModule
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from plugins.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types
|
from plugins.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types
|
||||||
from plugins.module_utils.module import SystemdUnitModule
|
from plugins.module_utils.module import SystemdUnitModule
|
||||||
|
@ -25,15 +23,9 @@ class Module(SystemdUnitModule):
|
||||||
name = "mount"
|
name = "mount"
|
||||||
module_spec = dict(
|
module_spec = dict(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
fs=Types.str(
|
fs=Types.str(required=True, help="The filesystem that is used for the mount"),
|
||||||
required=True, help="The filesystem that is used for the mount"
|
where=Types.path(required=True, help="The Path where the filesystem is mounted to"),
|
||||||
),
|
what=Types.str(required=True, help="The device or an string that will be mounted"),
|
||||||
where=Types.path(
|
|
||||||
required=True, help="The Path where the filesystem is mounted to"
|
|
||||||
),
|
|
||||||
what=Types.str(
|
|
||||||
required=True, help="The device or an string that will be mounted"
|
|
||||||
),
|
|
||||||
state=Types.str(
|
state=Types.str(
|
||||||
choices=("present", "absent"),
|
choices=("present", "absent"),
|
||||||
default="present",
|
default="present",
|
||||||
|
@ -55,9 +47,7 @@ class Module(SystemdUnitModule):
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
self.mountdir = pathlib.Path(self.params["where"])
|
self.mountdir = pathlib.Path(self.params["where"])
|
||||||
self.unitfile = SYSTEMD_SERVICE_CONFIG.joinpath(
|
self.unitfile = SYSTEMD_SERVICE_CONFIG.joinpath(self.mountdir.relative_to("/").as_posix().replace("/", "-")).with_suffix(".mount")
|
||||||
self.mountdir.relative_to("/").as_posix().replace("/", "-")
|
|
||||||
).with_suffix(".mount")
|
|
||||||
self.__unit = None
|
self.__unit = None
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
|
@ -72,9 +62,7 @@ class Module(SystemdUnitModule):
|
||||||
return self.__unit
|
return self.__unit
|
||||||
|
|
||||||
def header(self) -> str:
|
def header(self) -> str:
|
||||||
return "[Unit]\nDescription={}\n".format(
|
return "[Unit]\nDescription={}\n".format(self.get("description", "Mount for {}".format(self.get("where"))))
|
||||||
self.get("description", "Mount for {}".format(self.get("where")))
|
|
||||||
)
|
|
||||||
|
|
||||||
def mount(self) -> str:
|
def mount(self) -> str:
|
||||||
output = "[Mount]\n"
|
output = "[Mount]\n"
|
||||||
|
@ -98,13 +86,9 @@ class Module(SystemdUnitModule):
|
||||||
return
|
return
|
||||||
systemctl = self.module.get_bin_path("systemctl", required=True)
|
systemctl = self.module.get_bin_path("systemctl", required=True)
|
||||||
self.module.run_command([systemctl, "daemon-reload"], check_rc=True)
|
self.module.run_command([systemctl, "daemon-reload"], check_rc=True)
|
||||||
(rc, _, _) = self.module.run_command(
|
(rc, _, _) = self.module.run_command([systemctl, "is-enabled", self.unitfile.name], check_rc=False)
|
||||||
[systemctl, "is-enabled", self.unitfile.name], check_rc=False
|
|
||||||
)
|
|
||||||
if rc == 0:
|
if rc == 0:
|
||||||
self.module.run_command(
|
self.module.run_command([systemctl, "restart", self.unitfile.name], check_rc=True)
|
||||||
[systemctl, "restart", self.unitfile.name], check_rc=True
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = """---
|
DOCUMENTATION = """---
|
||||||
|
|
|
@ -3,10 +3,8 @@ import pathlib
|
||||||
from typing import List, Union
|
from typing import List, Union
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import (
|
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||||
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
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||||
from plugins.module_utils.module import SystemdUnitModule
|
from plugins.module_utils.module import SystemdUnitModule
|
||||||
|
@ -30,22 +28,16 @@ class Module(SystemdUnitModule):
|
||||||
device=Types.str(help="The name of the network device"),
|
device=Types.str(help="The name of the network device"),
|
||||||
name=Types.str(required=True, help="name of the unit"),
|
name=Types.str(required=True, help="name of the unit"),
|
||||||
description=Types.str(help="An optional description"),
|
description=Types.str(help="An optional description"),
|
||||||
dot=Types.bool(
|
dot=Types.bool(help="if DNS-over-TLS should be required or disabled. If it is unset, it will used if the server supports it"),
|
||||||
help="if DNS-over-TLS should be required or disabled. If it is unset, it will used if the server supports it"
|
|
||||||
),
|
|
||||||
dnssec=Types.bool(
|
dnssec=Types.bool(
|
||||||
"if the Domainqueries should require DNSSEC or not. If its missing, domains that have DNSSEC enabled will be validated, all others it will be assumed to be okay."
|
"if the Domainqueries should require DNSSEC or not. If its missing, domains that have DNSSEC enabled will be validated, all others it will be assumed to be okay."
|
||||||
),
|
),
|
||||||
dns=Types.list(elements=str, help="List of DNS-Servers"),
|
dns=Types.list(elements=str, help="List of DNS-Servers"),
|
||||||
domain=Types.list(
|
domain=Types.list(elements=str, help="List of domains that are on this device"),
|
||||||
elements=str, help="List of domains that are on this device"
|
|
||||||
),
|
|
||||||
defaultdns=Types.bool(
|
defaultdns=Types.bool(
|
||||||
help="If the DNS-Server(s) on this device should be used for all domains that are not set on other devices"
|
help="If the DNS-Server(s) on this device should be used for all domains that are not set on other devices"
|
||||||
),
|
),
|
||||||
address=Types.list(
|
address=Types.list(elements=str, required=True, help="IP-Addresses of this networkdevice"),
|
||||||
elements=str, required=True, help="IP-Addresses of this networkdevice"
|
|
||||||
),
|
|
||||||
route=Types.list(
|
route=Types.list(
|
||||||
elements=str,
|
elements=str,
|
||||||
help="Routes of networks that can be reached with this device",
|
help="Routes of networks that can be reached with this device",
|
||||||
|
@ -56,9 +48,7 @@ class Module(SystemdUnitModule):
|
||||||
)
|
)
|
||||||
|
|
||||||
def prepare(self):
|
def prepare(self):
|
||||||
self.unitfile = SYSTEMD_NETWORK_CONFIG.joinpath(self.get("name")).with_suffix(
|
self.unitfile = SYSTEMD_NETWORK_CONFIG.joinpath(self.get("name")).with_suffix(".network")
|
||||||
".network"
|
|
||||||
)
|
|
||||||
self.__unit = None
|
self.__unit = None
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
|
@ -98,12 +88,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(
|
options.append("DNSOverTLS={}".format(boolconvert(self.get("dot", "opportunistic"))))
|
||||||
"DNSOverTLS={}".format(boolconvert(self.get("dot", "opportunistic")))
|
options.append("DNSSEC={}".format(boolconvert(self.get("dnssec", "allow-downgrade"))))
|
||||||
)
|
|
||||||
options.append(
|
|
||||||
"DNSSEC={}".format(boolconvert(self.get("dnssec", "allow-downgrade")))
|
|
||||||
)
|
|
||||||
except KeyError:
|
except KeyError:
|
||||||
pass
|
pass
|
||||||
output += "\n".join(options)
|
output += "\n".join(options)
|
||||||
|
|
Laden…
In neuem Issue referenzieren