Commits vergleichen
Keine gemeinsamen Commits. "31b5fa26a8fc7a5db31965e053f845189485e71c" und "3d528fe1a6e03c537669f7a70640b7a20ab82725" haben vollständig unterschiedliche Historien.
31b5fa26a8
...
3d528fe1a6
|
@ -1,26 +1,10 @@
|
||||||
=====================================
|
=====================================
|
||||||
sebastian.systemd 0.4.3 Release Notes
|
sebastian.systemd 0.4.0 Release Notes
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
|
||||||
v0.4.3
|
|
||||||
======
|
|
||||||
|
|
||||||
Changelog
|
|
||||||
---------
|
|
||||||
|
|
||||||
added new options to system_service
|
|
||||||
|
|
||||||
v0.4.2
|
|
||||||
======
|
|
||||||
|
|
||||||
Changelog
|
|
||||||
---------
|
|
||||||
|
|
||||||
upgraded to the new method used by sebastian.base
|
|
||||||
|
|
||||||
v0.4.0
|
v0.4.0
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|
2
Makefile
2
Makefile
|
@ -9,7 +9,7 @@ docs: format
|
||||||
update-doc
|
update-doc
|
||||||
|
|
||||||
release: changelog docs
|
release: changelog docs
|
||||||
ansible-galaxy collection build --output-path dist
|
ansible-galaxy collection build
|
||||||
|
|
||||||
upload: release
|
upload: release
|
||||||
./upload.sh
|
./upload.sh
|
||||||
|
|
|
@ -66,11 +66,3 @@ releases:
|
||||||
release_date: "2024-02-24"
|
release_date: "2024-02-24"
|
||||||
changes:
|
changes:
|
||||||
release_summary: added timer module
|
release_summary: added timer module
|
||||||
0.4.2:
|
|
||||||
release_date: "2024-03-09"
|
|
||||||
changes:
|
|
||||||
release_summary: upgraded to the new method used by sebastian.base
|
|
||||||
0.4.3:
|
|
||||||
release_date: "2024-03-09"
|
|
||||||
changes:
|
|
||||||
release_summary: added new options to system_service
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
---
|
---
|
||||||
namespace: sebastian
|
namespace: sebastian
|
||||||
name: systemd
|
name: systemd
|
||||||
version: 0.4.3
|
version: 0.4.1
|
||||||
|
|
||||||
readme: README.md
|
readme: README.md
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ tags:
|
||||||
- systemd
|
- systemd
|
||||||
- linux
|
- linux
|
||||||
dependencies:
|
dependencies:
|
||||||
sebastian.base: ">=0.4.0"
|
sebastian.base: ">=0.3.1"
|
||||||
repository: https://gitea.sebastian-tobie.de/ansible/ansible-systemd.git
|
repository: https://gitea.sebastian-tobie.de/ansible/ansible-systemd.git
|
||||||
# documentation: http://docs.example.com
|
# documentation: http://docs.example.com
|
||||||
homepage: https://gitea.sebastian-tobie.de/ansible/ansible-systemd
|
homepage: https://gitea.sebastian-tobie.de/ansible/ansible-systemd
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import pathlib
|
import pathlib
|
||||||
from typing import List, Optional
|
from typing import List
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_module.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types, modspec
|
from ansible_module.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types, modspec
|
||||||
|
@ -54,10 +54,10 @@ class Module(SystemdUnitModule): # type: ignore
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
if self.__unit is None:
|
if self.__unit is None:
|
||||||
self.__unit = self._unit(self.match(), self.link())
|
self.__unit = "\n".join((self.match(), self.link()))
|
||||||
return self.__unit
|
return self.__unit
|
||||||
|
|
||||||
def match(self) -> Optional[str]:
|
def match(self) -> str:
|
||||||
options = self.map_param(
|
options = self.map_param(
|
||||||
mac="MACAddress",
|
mac="MACAddress",
|
||||||
permanentmac="PermanentAddress",
|
permanentmac="PermanentAddress",
|
||||||
|
@ -67,11 +67,9 @@ class Module(SystemdUnitModule): # type: ignore
|
||||||
kind="Kind",
|
kind="Kind",
|
||||||
virtualization="Virtualization",
|
virtualization="Virtualization",
|
||||||
)
|
)
|
||||||
if len(options) == 0:
|
|
||||||
return None
|
|
||||||
return "[Match]\n" + "".join(options)
|
return "[Match]\n" + "".join(options)
|
||||||
|
|
||||||
def link(self) -> Optional[str]:
|
def link(self) -> str:
|
||||||
options = []
|
options = []
|
||||||
if self.get("description", False):
|
if self.get("description", False):
|
||||||
options.append("Description={}\n".format(self.get("description", False)))
|
options.append("Description={}\n".format(self.get("description", False)))
|
||||||
|
@ -79,8 +77,6 @@ class Module(SystemdUnitModule): # type: ignore
|
||||||
options.append("Name={}\n".format(self.get("name", False)))
|
options.append("Name={}\n".format(self.get("name", False)))
|
||||||
if self.get("mtu", False):
|
if self.get("mtu", False):
|
||||||
options.append("MTUBytes={}\n".format(self.get("mtu", False)))
|
options.append("MTUBytes={}\n".format(self.get("mtu", False)))
|
||||||
if len(options) == 0:
|
|
||||||
return None
|
|
||||||
return "[Link]\n" + "".join(options)
|
return "[Link]\n" + "".join(options)
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
|
|
|
@ -18,7 +18,7 @@ OPTION_MAPPING = dict(
|
||||||
|
|
||||||
|
|
||||||
@installable
|
@installable
|
||||||
class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore
|
||||||
"""Creates an systemd mount"""
|
"""Creates an systemd mount"""
|
||||||
|
|
||||||
name = "mount"
|
name = "mount"
|
||||||
|
@ -45,25 +45,26 @@ class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
if self.__unit is None:
|
if self.__unit is None:
|
||||||
self.__unit = self._unit(
|
self.__unit = "\n".join(
|
||||||
self.header(),
|
(
|
||||||
self.mount(),
|
self.header(),
|
||||||
self.install(), # type: ignore[misc,call-arg]
|
self.mount(),
|
||||||
|
self.install(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return self.__unit
|
return self.__unit
|
||||||
|
|
||||||
def header(self) -> str:
|
def header(self) -> str:
|
||||||
description = self.get("description", "Mount for {}".format(self.get("where")))
|
return "[Unit]\nDescription={}\n".format(self.get("description", "Mount for {}".format(self.get("where"))))
|
||||||
return f"[Unit]\nDescription={description}\n"
|
|
||||||
|
|
||||||
def mount(self) -> str:
|
def mount(self) -> str:
|
||||||
options = []
|
output = "[Mount]\n"
|
||||||
options.append("Where={}\n".format(self.get("where")))
|
output += "Where={}\n".format(self.get("where"))
|
||||||
options.append("What={}\n".format(self.get("what")))
|
output += "What={}\n".format(self.get("what"))
|
||||||
options.append("Type={}\n".format(self.get("fs")))
|
output += "Type={}\n".format(self.get("fs"))
|
||||||
if self.get("options", False):
|
if self.get("options", False):
|
||||||
options.append("Options={}\n".format(",".join(self.get("options"))))
|
output += "Options={}\n".format(",".join(self.get("options")))
|
||||||
return "[Mount]\n" + "".join(options)
|
return output
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = """---
|
DOCUMENTATION = """---
|
||||||
|
|
|
@ -75,65 +75,55 @@ class Module(SystemdUnitModule):
|
||||||
parts = [self.match(), self.netdev()]
|
parts = [self.match(), self.netdev()]
|
||||||
if kind != "dummy":
|
if kind != "dummy":
|
||||||
parts.append(getattr(self, kind)())
|
parts.append(getattr(self, kind)())
|
||||||
self.__unit = self._unit(*parts)
|
self.__unit = "\n".join(parts)
|
||||||
return self.__unit
|
return self.__unit
|
||||||
|
|
||||||
def match(self) -> Optional[str]:
|
def match(self) -> str:
|
||||||
options = self.map_param(
|
options = self.map_param(
|
||||||
host="Host",
|
host="Host",
|
||||||
kernelcmd="KernelCommandLine",
|
kernelcmd="KernelCommandLine",
|
||||||
virtualization="Virtualization",
|
virtualization="Virtualization",
|
||||||
)
|
)
|
||||||
if len(options) == 0:
|
|
||||||
return None
|
|
||||||
return "[Match]\n" + "".join(options)
|
return "[Match]\n" + "".join(options)
|
||||||
|
|
||||||
def netdev(self) -> Optional[str]:
|
def netdev(self) -> str:
|
||||||
options = self.map_param(
|
options = self.map_param(
|
||||||
description="Description",
|
description="Description",
|
||||||
name="Name",
|
name="Name",
|
||||||
kind="Kind",
|
kind="Kind",
|
||||||
)
|
)
|
||||||
if len(options) == 0:
|
|
||||||
return None
|
|
||||||
return "[NetDev]\n" + "".join(options)
|
return "[NetDev]\n" + "".join(options)
|
||||||
|
|
||||||
def bond(self) -> Optional[str]:
|
def bond(self) -> str:
|
||||||
options = self.map_param(
|
return "[Bond]\n" + "".join(
|
||||||
mode="Mode",
|
self.map_param(
|
||||||
minlinks="MinLinks",
|
mode="Mode",
|
||||||
|
minlinks="MinLinks",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if len(options) == 0:
|
|
||||||
return None
|
|
||||||
return "[Bond]\n" + "".join(options)
|
|
||||||
|
|
||||||
def bridge(self) -> Optional[str]:
|
def bridge(self) -> str:
|
||||||
options = self.map_param(
|
return "[Bridge]\n" + "".join(
|
||||||
stp="STP",
|
self.map_param(
|
||||||
priority="Priority",
|
stp="STP",
|
||||||
|
priority="Priority",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if len(options) == 0:
|
|
||||||
return None
|
|
||||||
return "[Bridge]\n" + "".join(options)
|
|
||||||
|
|
||||||
def wireguard(self) -> Optional[str]:
|
def wireguard(self) -> str:
|
||||||
options = self.map_param(
|
|
||||||
privatekey="PrivateKey",
|
|
||||||
privatekeyfile="PrivateKeyFile",
|
|
||||||
port="ListenPort",
|
|
||||||
)
|
|
||||||
port = self.get("port", False)
|
port = self.get("port", False)
|
||||||
if port not in (False, "auto") and (port < 1 or port > 65535):
|
if port not in (False, "auto") and (port < 1 or port > 65535):
|
||||||
raise ValueError("Port must be between 0 and 65536")
|
raise ValueError("Port must be between 0 and 65536")
|
||||||
if len(options) == 0:
|
return "[Wireguard]\n" + "".join(
|
||||||
return None
|
self.map_param(
|
||||||
return "[Wireguard]\n" + "".join(options)
|
privatekey="PrivateKey",
|
||||||
|
privatekeyfile="PrivateKeyFile",
|
||||||
|
port="ListenPort",
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
def vlan(self) -> Optional[str]:
|
def vlan(self) -> str:
|
||||||
options: list[str] = []
|
return ""
|
||||||
if len(options) == 0:
|
|
||||||
return None
|
|
||||||
return "[Vlan]\n" + "".join(options)
|
|
||||||
|
|
||||||
|
|
||||||
DOCUMENTATION = """---
|
DOCUMENTATION = """---
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import pathlib
|
import pathlib
|
||||||
from typing import List, Optional, Union
|
from typing import List, Union
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_module.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types, modspec, systemdbool
|
from ansible_module.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types, modspec, systemdbool
|
||||||
|
@ -36,7 +36,7 @@ class Module(SystemdUnitModule): # type: ignore
|
||||||
),
|
),
|
||||||
masquerade=Types.str(
|
masquerade=Types.str(
|
||||||
help="how the packets are modified to look like the come from the computer itself.",
|
help="how the packets are modified to look like the come from the computer itself.",
|
||||||
choices=("true", "false", "both", "ipv4", "ipv6", "no"),
|
choices=("true", "false", "both", "ipv4", "ipv6"),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
required_if=(("defaultdns", True, ("dns",), False),),
|
required_if=(("defaultdns", True, ("dns",), False),),
|
||||||
|
@ -49,46 +49,56 @@ class Module(SystemdUnitModule): # type: ignore
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
if self.__unit is None:
|
if self.__unit is None:
|
||||||
self.__unit = self._unit(
|
self.__unit = "\n".join(
|
||||||
self.match(),
|
(
|
||||||
self.network(),
|
self.match(),
|
||||||
self.addresses(),
|
self.network(),
|
||||||
self.routes(),
|
self.addresses(),
|
||||||
|
self.routes(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return self.__unit
|
return self.__unit
|
||||||
|
|
||||||
def match(self) -> Optional[str]:
|
def match(self) -> str:
|
||||||
matches = self.map_param(
|
matches = []
|
||||||
mac="MACAddress",
|
return "[Match]\n" + "".join(
|
||||||
device="Name",
|
self.map_param(
|
||||||
virtualization="Virtualization",
|
mac="MACAddress",
|
||||||
|
device="Name",
|
||||||
|
virtualization="Virtualization",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if len(matches) == 0:
|
|
||||||
return None
|
|
||||||
return "[Match]\n" + "".join(matches)
|
|
||||||
|
|
||||||
def network(self) -> Optional[str]:
|
def network(self) -> str:
|
||||||
|
output = "[Network]\n"
|
||||||
options = []
|
options = []
|
||||||
if self.get("description", None) is None:
|
try:
|
||||||
options.append("Description={}".format(self.get("description")))
|
options.append("Description={}".format(self.get("description")))
|
||||||
server: str
|
except KeyError:
|
||||||
for server in self.get("dns", []):
|
pass
|
||||||
options.append(f"DNS={server}")
|
try:
|
||||||
options.append("DNSDefaultRoute={}".format(self.get("defaultdns", False)))
|
for server in self.get("dns", []):
|
||||||
if self.get("domain", False):
|
options.append(f"DNS={server}")
|
||||||
options.append("Domains={}".format(" ".join(self.get("domain"))))
|
options.append("DNSDefaultRoute={}".format(self.get("defaultdns", False)))
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
domain = self.get("domain")
|
||||||
|
self.set("domainlog", str(domain))
|
||||||
|
options.append("Domains={}".format(" ".join(domain)))
|
||||||
options.append("DNSOverTLS={}".format(systemdbool(self.get("dot", "opportunistic"))))
|
options.append("DNSOverTLS={}".format(systemdbool(self.get("dot", "opportunistic"))))
|
||||||
options.append("DNSSEC={}".format(systemdbool(self.get("dnssec", "allow-downgrade"))))
|
options.append("DNSSEC={}".format(systemdbool(self.get("dnssec", "allow-downgrade"))))
|
||||||
if self.get("masquerade", None) is not None:
|
except KeyError:
|
||||||
masquerade: str = self.get("masquerade")
|
pass
|
||||||
|
if self.get("masquerade", -1) != -1:
|
||||||
|
masquerade = self.get("masquerade")
|
||||||
if masquerade == "true":
|
if masquerade == "true":
|
||||||
masquerade = "both"
|
masquerade = "both"
|
||||||
elif masquerade == "false":
|
elif masquerade == "false":
|
||||||
masquerade = "no"
|
masquerade = "no"
|
||||||
options.append(f"IPMasquerade={masquerade}")
|
options.append(f"IPMasquerade={masquerade}")
|
||||||
if len(options) == 0:
|
output += "\n".join(options)
|
||||||
return None
|
return output
|
||||||
return "[Network]\n" + "".join(options)
|
|
||||||
|
|
||||||
def addresses(self) -> str:
|
def addresses(self) -> str:
|
||||||
output = []
|
output = []
|
||||||
|
@ -96,13 +106,13 @@ class Module(SystemdUnitModule): # type: ignore
|
||||||
output.append(f"[Address]\nAddress={address}\n")
|
output.append(f"[Address]\nAddress={address}\n")
|
||||||
return "\n".join(output)
|
return "\n".join(output)
|
||||||
|
|
||||||
def routes(self) -> Optional[str]:
|
def routes(self) -> str:
|
||||||
output = []
|
output = []
|
||||||
routes: list[str] = self.get("route", [])
|
routes = self.get("route", [])
|
||||||
|
self.set("routes", routes)
|
||||||
for gw in routes:
|
for gw in routes:
|
||||||
output.append(f"[Route]\nGateway={gw}\nGatewayOnLink=yes\nQuickAck=yes\n")
|
output.append(f"[Route]\nGateway={gw}\nGatewayOnLink=yes\nQuickAck=yes\n")
|
||||||
if len(output) == 0:
|
self.set("routes", output)
|
||||||
return None
|
|
||||||
return "\n".join(output)
|
return "\n".join(output)
|
||||||
|
|
||||||
|
|
||||||
|
@ -195,7 +205,6 @@ options:
|
||||||
- both
|
- both
|
||||||
- ipv4
|
- ipv4
|
||||||
- ipv6
|
- ipv6
|
||||||
- 'no'
|
|
||||||
description:
|
description:
|
||||||
- how the packets are modified to look like the come from the computer itself.
|
- how the packets are modified to look like the come from the computer itself.
|
||||||
required: false
|
required: false
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import pathlib
|
import pathlib
|
||||||
from typing import List, Optional, Union
|
from typing import List, Union
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_module.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types, modspec
|
from ansible_module.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types, modspec
|
||||||
|
@ -47,26 +47,29 @@ class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore
|
||||||
self.unitfile = (SYSTEMD_SERVICE_CONFIG / self.get("name")).with_suffix(".socket")
|
self.unitfile = (SYSTEMD_SERVICE_CONFIG / self.get("name")).with_suffix(".socket")
|
||||||
self.__unit = None
|
self.__unit = None
|
||||||
|
|
||||||
def socket(self) -> Optional[str]:
|
def socket(self):
|
||||||
section = self.map_param(
|
section = "[Socket]\n"
|
||||||
stream="ListenStream",
|
section += "".join(
|
||||||
datagram="ListenDatagram",
|
self.map_param(
|
||||||
sequential="ListenSequential",
|
stream="ListenStream",
|
||||||
fifo="ListenFIFO",
|
datagram="ListenDatagram",
|
||||||
socketuser="SocketUser",
|
sequential="ListenSequential",
|
||||||
socketgroup="SocketGroup",
|
fifo="ListenFIFO",
|
||||||
socketmode="SocketMode",
|
socketuser="SocketUser",
|
||||||
|
socketgroup="SocketGroup",
|
||||||
|
socketmode="SocketMode",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
if len(section) == 0:
|
return section
|
||||||
return None
|
|
||||||
return "[Socket]\n" + "".join(section)
|
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
if self.__unit is None:
|
if self.__unit is None:
|
||||||
self.__unit = self._unit(
|
self.__unit = "\n".join(
|
||||||
self.header(),
|
(
|
||||||
self.socket(),
|
self.header(),
|
||||||
self.install(), # type: ignore[call-arg,misc]
|
self.socket(),
|
||||||
|
self.install(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return self.__unit
|
return self.__unit
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ except ImportError:
|
||||||
|
|
||||||
|
|
||||||
@installable
|
@installable
|
||||||
class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
class Module(SystemdUnitModule, SystemdReloadMixin):
|
||||||
"""Creates System Services units"""
|
"""Creates System Services units"""
|
||||||
|
|
||||||
name = "system_service"
|
name = "system_service"
|
||||||
|
@ -37,8 +37,6 @@ class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
||||||
required=True,
|
required=True,
|
||||||
help="command or list of commands that are started as main programm. Multiple commands are only allowed in a oneshot command",
|
help="command or list of commands that are started as main programm. Multiple commands are only allowed in a oneshot command",
|
||||||
),
|
),
|
||||||
stop=Types.str(help="command that is started to stop the main program."),
|
|
||||||
remain=Types.bool(help="should the service remain as started after the command exited"),
|
|
||||||
post=Types.list(str, help="Command or list of commands that are started after the main command(s) stopped without problems."),
|
post=Types.list(str, help="Command or list of commands that are started after the main command(s) stopped without problems."),
|
||||||
environmentfile=Types.list(
|
environmentfile=Types.list(
|
||||||
elements=str,
|
elements=str,
|
||||||
|
@ -88,11 +86,6 @@ class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
||||||
statedirectory=Types.str(
|
statedirectory=Types.str(
|
||||||
help="creates an unit specific state directory in /var/lib and sets the env var STATE_DIRECTORY with the path to it. Its cleaned up after the unit is stopped"
|
help="creates an unit specific state directory in /var/lib and sets the env var STATE_DIRECTORY with the path to it. Its cleaned up after the unit is stopped"
|
||||||
),
|
),
|
||||||
runtimedirectory=Types.str(
|
|
||||||
help="creates an unit specific runtime directory in /run and sets the env var RUNTIME_DIRECTORY with the path to it. Its cleaned up after the unit is stopped"
|
|
||||||
),
|
|
||||||
restart=Types.str(),
|
|
||||||
restartsec=Types.str(),
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -102,7 +95,8 @@ class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
||||||
if self.get("type", "simple") != "oneshot" and len(self.get("start")) > 1:
|
if self.get("type", "simple") != "oneshot" and len(self.get("start")) > 1:
|
||||||
self.module.fail_json("only oneshot services are allowed to have multiple start commands", **self.result)
|
self.module.fail_json("only oneshot services are allowed to have multiple start commands", **self.result)
|
||||||
|
|
||||||
def service(self) -> str:
|
def service(self):
|
||||||
|
section = "[Service]\n"
|
||||||
params = []
|
params = []
|
||||||
if self.get("environment", False):
|
if self.get("environment", False):
|
||||||
for env in self.get("environment"):
|
for env in self.get("environment"):
|
||||||
|
@ -112,7 +106,6 @@ class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
||||||
type="Type",
|
type="Type",
|
||||||
pre="ExecStartPre",
|
pre="ExecStartPre",
|
||||||
start="ExecStart",
|
start="ExecStart",
|
||||||
stop="ExecStop",
|
|
||||||
post="ExecStartPost",
|
post="ExecStartPost",
|
||||||
serviceuser="User",
|
serviceuser="User",
|
||||||
servicegroup="Group",
|
servicegroup="Group",
|
||||||
|
@ -126,21 +119,20 @@ class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
||||||
execpath="ExecPaths",
|
execpath="ExecPaths",
|
||||||
noexecpath="NoExecPaths",
|
noexecpath="NoExecPaths",
|
||||||
statedirectory="StateDirectory",
|
statedirectory="StateDirectory",
|
||||||
runtimedirectory="RuntimeDirectory",
|
|
||||||
nonewprivileges="NoNewPriviledges",
|
nonewprivileges="NoNewPriviledges",
|
||||||
remain="RemainAfterExit",
|
|
||||||
restart="Restart",
|
|
||||||
restartsec="RestartSec",
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
return "[Service]\n" + "".join(params)
|
section += "".join(params)
|
||||||
|
return section
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
if self.__unit is None:
|
if self.__unit is None:
|
||||||
self.__unit = self._unit(
|
self.__unit = "\n".join(
|
||||||
self.header(),
|
(
|
||||||
self.service(),
|
self.header(),
|
||||||
self.install(), # type: ignore[call-arg,misc]
|
self.service(),
|
||||||
|
self.install(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return self.__unit
|
return self.__unit
|
||||||
|
|
||||||
|
@ -254,7 +246,7 @@ options:
|
||||||
pre:
|
pre:
|
||||||
default: []
|
default: []
|
||||||
description:
|
description:
|
||||||
- command or list of commands that are started before the main command
|
- command or list of commands that are started before the main command(Types.str)
|
||||||
elements: str
|
elements: str
|
||||||
required: false
|
required: false
|
||||||
type: list
|
type: list
|
||||||
|
@ -280,11 +272,6 @@ options:
|
||||||
additionally /etc and if strict all except /proc, /sys and /dev
|
additionally /etc and if strict all except /proc, /sys and /dev
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
remain:
|
|
||||||
description:
|
|
||||||
- should the service remain as started after the command exited
|
|
||||||
required: false
|
|
||||||
type: bool
|
|
||||||
required_by:
|
required_by:
|
||||||
default: []
|
default: []
|
||||||
description:
|
description:
|
||||||
|
@ -300,12 +287,6 @@ options:
|
||||||
elements: str
|
elements: str
|
||||||
required: false
|
required: false
|
||||||
type: list
|
type: list
|
||||||
restart:
|
|
||||||
required: false
|
|
||||||
type: str
|
|
||||||
restartsec:
|
|
||||||
required: false
|
|
||||||
type: str
|
|
||||||
ropath:
|
ropath:
|
||||||
default: []
|
default: []
|
||||||
description:
|
description:
|
||||||
|
@ -313,12 +294,6 @@ options:
|
||||||
elements: path
|
elements: path
|
||||||
required: false
|
required: false
|
||||||
type: list
|
type: list
|
||||||
runtimedirectory:
|
|
||||||
description:
|
|
||||||
- creates an unit specific runtime directory in /run and sets the env var RUNTIME_DIRECTORY
|
|
||||||
with the path to it. Its cleaned up after the unit is stopped
|
|
||||||
required: false
|
|
||||||
type: str
|
|
||||||
rwpath:
|
rwpath:
|
||||||
default: []
|
default: []
|
||||||
description:
|
description:
|
||||||
|
@ -351,11 +326,6 @@ options:
|
||||||
with the path to it. Its cleaned up after the unit is stopped
|
with the path to it. Its cleaned up after the unit is stopped
|
||||||
required: false
|
required: false
|
||||||
type: str
|
type: str
|
||||||
stop:
|
|
||||||
description:
|
|
||||||
- command that is started to stop the main program.
|
|
||||||
required: false
|
|
||||||
type: str
|
|
||||||
type:
|
type:
|
||||||
choices:
|
choices:
|
||||||
- simple
|
- simple
|
||||||
|
|
|
@ -13,7 +13,7 @@ __module_name__ = "TargetModule"
|
||||||
|
|
||||||
|
|
||||||
@installable
|
@installable
|
||||||
class TargetModule(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
class TargetModule(SystemdUnitModule, SystemdReloadMixin):
|
||||||
"""Creates Target units"""
|
"""Creates Target units"""
|
||||||
|
|
||||||
name = "target"
|
name = "target"
|
||||||
|
@ -35,16 +35,16 @@ class TargetModule(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
||||||
|
|
||||||
def header(self) -> str:
|
def header(self) -> str:
|
||||||
section = super().header()
|
section = super().header()
|
||||||
if section is None:
|
|
||||||
section = "[Unit]\n"
|
|
||||||
section += "AllowIsolate={}\n".format(systemdbool(self.get("allow_isolate", False)))
|
section += "AllowIsolate={}\n".format(systemdbool(self.get("allow_isolate", False)))
|
||||||
return section
|
return section
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
if self.__unit is None:
|
if self.__unit is None:
|
||||||
self.__unit = self._unit(
|
self.__unit = "\n".join(
|
||||||
self.header(),
|
(
|
||||||
self.install(), # type: ignore[call-arg,misc]
|
self.header(),
|
||||||
|
self.install(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return self.__unit
|
return self.__unit
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ __module_name__ = "TimerModule"
|
||||||
|
|
||||||
|
|
||||||
@installable
|
@installable
|
||||||
class TimerModule(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
class TimerModule(SystemdUnitModule, SystemdReloadMixin): # type: ignore
|
||||||
"""Creates Timer units"""
|
"""Creates Timer units"""
|
||||||
|
|
||||||
name = "timer"
|
name = "timer"
|
||||||
|
@ -56,14 +56,14 @@ class TimerModule(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
||||||
unit=Types.str(help="The name of the unit. only needed if its not {{name}}.service"),
|
unit=Types.str(help="The name of the unit. only needed if its not {{name}}.service"),
|
||||||
),
|
),
|
||||||
required_one_of=[
|
required_one_of=[
|
||||||
(
|
[
|
||||||
"onactive",
|
"onactive",
|
||||||
"onboot",
|
"onboot",
|
||||||
"onstartup",
|
"onstartup",
|
||||||
"onunitactive",
|
"onunitactive",
|
||||||
"onunitinactive",
|
"onunitinactive",
|
||||||
"oncalendar",
|
"oncalendar",
|
||||||
),
|
],
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -82,23 +82,19 @@ class TimerModule(SystemdUnitModule, SystemdReloadMixin): # type: ignore[misc]
|
||||||
onunitactive="OnUnitActiveSec",
|
onunitactive="OnUnitActiveSec",
|
||||||
onunitinactive="OnUnitInactiveSec",
|
onunitinactive="OnUnitInactiveSec",
|
||||||
oncalendar="OnCalendar",
|
oncalendar="OnCalendar",
|
||||||
persistent="Persistent",
|
|
||||||
randomdelay="RandomizedDelaySec",
|
|
||||||
fixdelay="FixedRandomDelay",
|
|
||||||
unit="Unit",
|
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
if len(params) == 0:
|
|
||||||
return None
|
|
||||||
section += "".join(params)
|
section += "".join(params)
|
||||||
return section
|
return section
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
if self.__unit is None:
|
if self.__unit is None:
|
||||||
self.__unit = self._unit(
|
self.__unit = "\n".join(
|
||||||
self.header(),
|
(
|
||||||
self.body(),
|
self.header(),
|
||||||
self.install(), # type: ignore[call-arg,misc]
|
self.body(),
|
||||||
|
self.install(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
return self.__unit
|
return self.__unit
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,3 @@ line-length = 140
|
||||||
atomic = true
|
atomic = true
|
||||||
profile = "black"
|
profile = "black"
|
||||||
line_length = 140
|
line_length = 140
|
||||||
|
|
||||||
[tool.mypy]
|
|
||||||
disable_error_code = ["import-untyped", "no-redef", "attr-defined"]
|
|
||||||
|
|
|
@ -3,4 +3,4 @@ user=$(yq -r .namespace galaxy.yml)
|
||||||
package=$(yq -r .name galaxy.yml)
|
package=$(yq -r .name galaxy.yml)
|
||||||
version=$(yq -r .version galaxy.yml)
|
version=$(yq -r .version galaxy.yml)
|
||||||
printf "Namespace: %s\nPackage: %s\nVersion: %s\nfile name: %s\n" $user $package $version "$user-$package-$version.tar.gz"
|
printf "Namespace: %s\nPackage: %s\nVersion: %s\nfile name: %s\n" $user $package $version "$user-$package-$version.tar.gz"
|
||||||
ansible-galaxy collection publish dist/*
|
curl -u sebastian --upload-file "${user}-${package}-${version}.tar.gz" "https://gitea.sebastian-tobie.de/api/packages/ansible/generic/${package}/${version}/${user}-${package}-${version}.tar.gz"
|
||||||
|
|
Laden…
In neuem Issue referenzieren