updated formatting
Dieser Commit ist enthalten in:
Ursprung
53057c18a2
Commit
52b5a96926
|
@ -3,10 +3,8 @@ import pathlib
|
|||
from typing import List
|
||||
|
||||
try:
|
||||
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.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||
from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule
|
||||
except ImportError:
|
||||
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||
from plugins.module_utils.module import SystemdUnitModule
|
||||
|
@ -19,21 +17,11 @@ class Module(SystemdUnitModule):
|
|||
module_spec = dict(
|
||||
argument_spec=dict(
|
||||
mac=Types.str(help="The Mac address of the device"),
|
||||
permanentmac=Types.str(
|
||||
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"
|
||||
),
|
||||
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."
|
||||
),
|
||||
permanentmac=Types.str(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"),
|
||||
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"),
|
||||
name=Types.str(required=True, help="The new name of the device"),
|
||||
mtu=Types.int(help="The maximum Transmission unit for the link"),
|
||||
|
@ -46,13 +34,9 @@ class Module(SystemdUnitModule):
|
|||
|
||||
def prepare(self):
|
||||
self.__unit = None
|
||||
newname = (
|
||||
self.get("name", "") or self.get("mac", "") or self.get("permanentmac", "")
|
||||
)
|
||||
newname = self.get("name", "") or self.get("mac", "") or self.get("permanentmac", "")
|
||||
newname = newname.replace(":", "").replace("/", "-").lower()
|
||||
self.unitfile = SYSTEMD_NETWORK_CONFIG.joinpath("50-" + newname).with_suffix(
|
||||
".link"
|
||||
)
|
||||
self.unitfile = SYSTEMD_NETWORK_CONFIG.joinpath("50-" + newname).with_suffix(".link")
|
||||
|
||||
def unit(self) -> str:
|
||||
if self.__unit is None:
|
||||
|
@ -64,9 +48,7 @@ class Module(SystemdUnitModule):
|
|||
if self.get("mac", False):
|
||||
options.append("MACAddress={}\n".format(self.get("mac", False)))
|
||||
if self.get("permanentmac", False):
|
||||
options.append(
|
||||
"PermanentAddress={}\n".format(self.get("permanentmac", False))
|
||||
)
|
||||
options.append("PermanentAddress={}\n".format(self.get("permanentmac", False)))
|
||||
if self.get("path", False):
|
||||
options.append("Path={}\n".format(self.get("path", False)))
|
||||
if self.get("driver", False):
|
||||
|
|
|
@ -3,10 +3,8 @@ import pathlib
|
|||
from typing import List, Optional
|
||||
|
||||
try:
|
||||
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import (
|
||||
SYSTEMD_SERVICE_CONFIG, Types)
|
||||
from ansible_collections.sebastian.systemd.plugins.module_utils.module import \
|
||||
SystemdUnitModule
|
||||
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types
|
||||
from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule
|
||||
except ImportError:
|
||||
from plugins.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types
|
||||
from plugins.module_utils.module import SystemdUnitModule
|
||||
|
@ -25,15 +23,9 @@ class Module(SystemdUnitModule):
|
|||
name = "mount"
|
||||
module_spec = dict(
|
||||
argument_spec=dict(
|
||||
fs=Types.str(
|
||||
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"
|
||||
),
|
||||
fs=Types.str(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"),
|
||||
state=Types.str(
|
||||
choices=("present", "absent"),
|
||||
default="present",
|
||||
|
@ -55,9 +47,7 @@ class Module(SystemdUnitModule):
|
|||
|
||||
def prepare(self):
|
||||
self.mountdir = pathlib.Path(self.params["where"])
|
||||
self.unitfile = SYSTEMD_SERVICE_CONFIG.joinpath(
|
||||
self.mountdir.relative_to("/").as_posix().replace("/", "-")
|
||||
).with_suffix(".mount")
|
||||
self.unitfile = SYSTEMD_SERVICE_CONFIG.joinpath(self.mountdir.relative_to("/").as_posix().replace("/", "-")).with_suffix(".mount")
|
||||
self.__unit = None
|
||||
|
||||
def unit(self) -> str:
|
||||
|
@ -72,9 +62,7 @@ class Module(SystemdUnitModule):
|
|||
return self.__unit
|
||||
|
||||
def header(self) -> str:
|
||||
return "[Unit]\nDescription={}\n".format(
|
||||
self.get("description", "Mount for {}".format(self.get("where")))
|
||||
)
|
||||
return "[Unit]\nDescription={}\n".format(self.get("description", "Mount for {}".format(self.get("where"))))
|
||||
|
||||
def mount(self) -> str:
|
||||
output = "[Mount]\n"
|
||||
|
@ -98,13 +86,9 @@ class Module(SystemdUnitModule):
|
|||
return
|
||||
systemctl = self.module.get_bin_path("systemctl", required=True)
|
||||
self.module.run_command([systemctl, "daemon-reload"], check_rc=True)
|
||||
(rc, _, _) = self.module.run_command(
|
||||
[systemctl, "is-enabled", self.unitfile.name], check_rc=False
|
||||
)
|
||||
(rc, _, _) = self.module.run_command([systemctl, "is-enabled", self.unitfile.name], check_rc=False)
|
||||
if rc == 0:
|
||||
self.module.run_command(
|
||||
[systemctl, "restart", self.unitfile.name], check_rc=True
|
||||
)
|
||||
self.module.run_command([systemctl, "restart", self.unitfile.name], check_rc=True)
|
||||
|
||||
|
||||
DOCUMENTATION = """---
|
||||
|
|
|
@ -3,10 +3,8 @@ import pathlib
|
|||
from typing import List, Union
|
||||
|
||||
try:
|
||||
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.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||
from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule
|
||||
except ImportError:
|
||||
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||
from plugins.module_utils.module import SystemdUnitModule
|
||||
|
@ -30,22 +28,16 @@ class Module(SystemdUnitModule):
|
|||
device=Types.str(help="The name of the network device"),
|
||||
name=Types.str(required=True, help="name of the unit"),
|
||||
description=Types.str(help="An optional description"),
|
||||
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"
|
||||
),
|
||||
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"),
|
||||
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."
|
||||
),
|
||||
dns=Types.list(elements=str, help="List of DNS-Servers"),
|
||||
domain=Types.list(
|
||||
elements=str, help="List of domains that are on this device"
|
||||
),
|
||||
domain=Types.list(elements=str, help="List of domains that are on this device"),
|
||||
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"
|
||||
),
|
||||
address=Types.list(
|
||||
elements=str, required=True, help="IP-Addresses of this networkdevice"
|
||||
),
|
||||
address=Types.list(elements=str, required=True, help="IP-Addresses of this networkdevice"),
|
||||
route=Types.list(
|
||||
elements=str,
|
||||
help="Routes of networks that can be reached with this device",
|
||||
|
@ -56,9 +48,7 @@ class Module(SystemdUnitModule):
|
|||
)
|
||||
|
||||
def prepare(self):
|
||||
self.unitfile = SYSTEMD_NETWORK_CONFIG.joinpath(self.get("name")).with_suffix(
|
||||
".network"
|
||||
)
|
||||
self.unitfile = SYSTEMD_NETWORK_CONFIG.joinpath(self.get("name")).with_suffix(".network")
|
||||
self.__unit = None
|
||||
|
||||
def unit(self) -> str:
|
||||
|
@ -98,12 +88,8 @@ class Module(SystemdUnitModule):
|
|||
domain = self.get("domain")
|
||||
self.set("domainlog", str(domain))
|
||||
options.append("Domains={}".format(" ".join(domain)))
|
||||
options.append(
|
||||
"DNSOverTLS={}".format(boolconvert(self.get("dot", "opportunistic")))
|
||||
)
|
||||
options.append(
|
||||
"DNSSEC={}".format(boolconvert(self.get("dnssec", "allow-downgrade")))
|
||||
)
|
||||
options.append("DNSOverTLS={}".format(boolconvert(self.get("dot", "opportunistic"))))
|
||||
options.append("DNSSEC={}".format(boolconvert(self.get("dnssec", "allow-downgrade"))))
|
||||
except KeyError:
|
||||
pass
|
||||
output += "\n".join(options)
|
||||
|
|
Laden…
In neuem Issue referenzieren