renamed the modules
Dieser Commit ist enthalten in:
Ursprung
3923d2cedb
Commit
172cce0b04
|
@ -1,10 +1,26 @@
|
||||||
=====================================
|
=====================================
|
||||||
sebastian.systemd 0.1.1 Release Notes
|
sebastian.systemd 0.1.3 Release Notes
|
||||||
=====================================
|
=====================================
|
||||||
|
|
||||||
.. contents:: Topics
|
.. contents:: Topics
|
||||||
|
|
||||||
|
|
||||||
|
v0.1.3
|
||||||
|
======
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
---------
|
||||||
|
|
||||||
|
renamed all modules to names without systemd_ prefix
|
||||||
|
|
||||||
|
v0.1.2
|
||||||
|
======
|
||||||
|
|
||||||
|
Changelog
|
||||||
|
---------
|
||||||
|
|
||||||
|
Pfad der auflösung für Tests und autodoc geändert, weil Mitogen sonst blockiert
|
||||||
|
|
||||||
v0.1.1
|
v0.1.1
|
||||||
======
|
======
|
||||||
|
|
||||||
|
|
|
@ -25,3 +25,7 @@ releases:
|
||||||
changes:
|
changes:
|
||||||
release_date: '2023-04-15'
|
release_date: '2023-04-15'
|
||||||
release_summary: Pfad der auflösung für Tests und autodoc geändert, weil Mitogen sonst blockiert
|
release_summary: Pfad der auflösung für Tests und autodoc geändert, weil Mitogen sonst blockiert
|
||||||
|
0.1.3:
|
||||||
|
changes:
|
||||||
|
release_date: "2023-04-20"
|
||||||
|
release_summary: "renamed all modules to names without systemd_ prefix"
|
|
@ -1,9 +1,12 @@
|
||||||
import pathlib
|
import pathlib
|
||||||
from typing import Any, Callable, ClassVar, Dict, Optional, TypeVar, NoReturn, overload
|
from typing import (Any, Callable, ClassVar, Dict, NoReturn, Optional, TypeVar,
|
||||||
|
overload)
|
||||||
|
|
||||||
import ansible.module_utils.basic as basic
|
import ansible.module_utils.basic as basic
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import _sdict
|
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import \
|
||||||
|
_sdict
|
||||||
except ImportError:
|
except ImportError:
|
||||||
from plugins.module_utils.generic import _sdict
|
from plugins.module_utils.generic import _sdict
|
||||||
|
|
||||||
|
@ -52,7 +55,9 @@ class AnsibleModule(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def diff(
|
def diff(
|
||||||
self,diff: Optional[Dict[str, str]] = None,*,
|
self,
|
||||||
|
diff: Optional[Dict[str, str]] = None,
|
||||||
|
*,
|
||||||
before: Optional[str] = None,
|
before: Optional[str] = None,
|
||||||
after: Optional[str] = None,
|
after: Optional[str] = None,
|
||||||
before_header: Optional[str] = None,
|
before_header: Optional[str] = None,
|
||||||
|
@ -73,7 +78,9 @@ class AnsibleModule(object):
|
||||||
if after_header is not None:
|
if after_header is not None:
|
||||||
diff["after_header"] = after_header
|
diff["after_header"] = after_header
|
||||||
else:
|
else:
|
||||||
raise TypeError("only diff or before and after can be set, not both of them")
|
raise TypeError(
|
||||||
|
"only diff or before and after can be set, not both of them"
|
||||||
|
)
|
||||||
self.result["diff"].append(diff)
|
self.result["diff"].append(diff)
|
||||||
|
|
||||||
def get(self, key: str, default: T = None) -> T:
|
def get(self, key: str, default: T = None) -> T:
|
||||||
|
@ -106,7 +113,8 @@ class AnsibleModule(object):
|
||||||
|
|
||||||
def __call__(self) -> NoReturn:
|
def __call__(self) -> NoReturn:
|
||||||
"""This calls the module. first prepare is called and then check or run, depending on the check mode.
|
"""This calls the module. first prepare is called and then check or run, depending on the check mode.
|
||||||
If an exception is raised this is catched and the module automatically fails with an traceback"""
|
If an exception is raised this is catched and the module automatically fails with an traceback
|
||||||
|
"""
|
||||||
self.prepare()
|
self.prepare()
|
||||||
print(self.changed)
|
print(self.changed)
|
||||||
try:
|
try:
|
||||||
|
@ -218,7 +226,9 @@ class SystemdUnitModule(AnsibleModule):
|
||||||
def check(self):
|
def check(self):
|
||||||
self.unitfile_gen()
|
self.unitfile_gen()
|
||||||
if not self.unitfile.exists():
|
if not self.unitfile.exists():
|
||||||
self.diff(before="", after=self.unit(), before_header=self.unitfile.as_posix())
|
self.diff(
|
||||||
|
before="", after=self.unit(), before_header=self.unitfile.as_posix()
|
||||||
|
)
|
||||||
self.changed = True
|
self.changed = True
|
||||||
else:
|
else:
|
||||||
if self.module.sha256(self.unitfile.as_posix()) != self.module.sha256(
|
if self.module.sha256(self.unitfile.as_posix()) != self.module.sha256(
|
||||||
|
|
|
@ -3,8 +3,10 @@ import pathlib
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
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 (
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule
|
SYSTEMD_NETWORK_CONFIG, Types)
|
||||||
|
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
|
||||||
|
@ -13,7 +15,7 @@ except ImportError:
|
||||||
class Module(SystemdUnitModule):
|
class Module(SystemdUnitModule):
|
||||||
"""generates an systemd-networkd link"""
|
"""generates an systemd-networkd link"""
|
||||||
|
|
||||||
name = "systemd_link"
|
name = "link"
|
||||||
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"),
|
||||||
|
@ -48,7 +50,9 @@ class Module(SystemdUnitModule):
|
||||||
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(".link")
|
self.unitfile = SYSTEMD_NETWORK_CONFIG.joinpath("50-" + newname).with_suffix(
|
||||||
|
".link"
|
||||||
|
)
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
if self.__unit is None:
|
if self.__unit is None:
|
||||||
|
@ -104,7 +108,7 @@ class Module(SystemdUnitModule):
|
||||||
DOCUMENTATION = """---
|
DOCUMENTATION = """---
|
||||||
description:
|
description:
|
||||||
- generates an systemd-networkd link
|
- generates an systemd-networkd link
|
||||||
module: systemd_link
|
module: link
|
||||||
options:
|
options:
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
|
@ -3,8 +3,10 @@ import pathlib
|
||||||
from typing import List, Optional
|
from typing import List, Optional
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types
|
from ansible_collections.sebastian.systemd.plugins.module_utils.generic import (
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule
|
SYSTEMD_SERVICE_CONFIG, Types)
|
||||||
|
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
|
||||||
|
@ -20,7 +22,7 @@ OPTION_MAPPING = dict(
|
||||||
class Module(SystemdUnitModule):
|
class Module(SystemdUnitModule):
|
||||||
"""Creates an systemd mount"""
|
"""Creates an systemd mount"""
|
||||||
|
|
||||||
name = "systemd_mount"
|
name = "mount"
|
||||||
module_spec = dict(
|
module_spec = dict(
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
fs=Types.str(
|
fs=Types.str(
|
||||||
|
@ -108,7 +110,7 @@ class Module(SystemdUnitModule):
|
||||||
DOCUMENTATION = """---
|
DOCUMENTATION = """---
|
||||||
description:
|
description:
|
||||||
- Creates an systemd mount
|
- Creates an systemd mount
|
||||||
module: systemd_mount
|
module: mount
|
||||||
options:
|
options:
|
||||||
description:
|
description:
|
||||||
description:
|
description:
|
|
@ -3,8 +3,10 @@ import pathlib
|
||||||
from typing import List, Union
|
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 (
|
||||||
from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule
|
SYSTEMD_NETWORK_CONFIG, Types)
|
||||||
|
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
|
||||||
|
@ -21,27 +23,42 @@ def boolconvert(b: Union[bool, str]) -> str:
|
||||||
class Module(SystemdUnitModule):
|
class Module(SystemdUnitModule):
|
||||||
"""Sets up the systemd network unit"""
|
"""Sets up the systemd network unit"""
|
||||||
|
|
||||||
name = "systemd_network"
|
name = "network"
|
||||||
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"),
|
||||||
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(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(
|
||||||
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."),
|
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"),
|
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(
|
||||||
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"),
|
elements=str, help="List of domains that are on this device"
|
||||||
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"),
|
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"
|
||||||
|
),
|
||||||
|
route=Types.list(
|
||||||
|
elements=str,
|
||||||
|
help="Routes of networks that can be reached with this device",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
required_if=(("defaultdns", True, ("dns",), False),),
|
required_if=(("defaultdns", True, ("dns",), False),),
|
||||||
required_one_of=(("mac", "device"),),
|
required_one_of=(("mac", "device"),),
|
||||||
)
|
)
|
||||||
|
|
||||||
def prepare(self):
|
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
|
self.__unit = None
|
||||||
|
|
||||||
def unit(self) -> str:
|
def unit(self) -> str:
|
||||||
|
@ -111,7 +128,7 @@ class Module(SystemdUnitModule):
|
||||||
DOCUMENTATION = """---
|
DOCUMENTATION = """---
|
||||||
description:
|
description:
|
||||||
- Sets up the systemd network unit
|
- Sets up the systemd network unit
|
||||||
module: systemd_network
|
module: network
|
||||||
options:
|
options:
|
||||||
address:
|
address:
|
||||||
description:
|
description:
|
|
@ -1,7 +1,7 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
import re
|
|
||||||
import pathlib
|
|
||||||
import importlib
|
import importlib
|
||||||
|
import pathlib
|
||||||
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.append(".")
|
sys.path.append(".")
|
||||||
|
@ -21,7 +21,10 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
print("Error loading Module of File: {}. No Module or __module_name__ defined".format(modfile))
|
print("Error loading Module of File: {}. No Module or __module_name__ defined".format(modfile))
|
||||||
continue
|
continue
|
||||||
|
try:
|
||||||
moddoc = module.doc()
|
moddoc = module.doc()
|
||||||
|
except AttributeError:
|
||||||
|
print("Broken module. skipping {}".format(modfile))
|
||||||
moddata = modfile.read_text()
|
moddata = modfile.read_text()
|
||||||
match = regex.search(moddata)
|
match = regex.search(moddata)
|
||||||
if not match:
|
if not match:
|
||||||
|
|
Laden…
In neuem Issue referenzieren