current try
Dieser Commit ist enthalten in:
Ursprung
491270a022
Commit
c584ff60f7
|
@ -2,7 +2,10 @@ import pathlib
|
|||
from typing import Any, Callable, ClassVar, Dict, Optional, TypeVar, NoReturn, overload
|
||||
|
||||
import ansible.module_utils.basic as basic
|
||||
from ansible.module_utils.generic import _sdict
|
||||
try:
|
||||
from ansible.module_utils.generic import _sdict
|
||||
except ImportError:
|
||||
from plugins.module_utils.generic import _sdict
|
||||
|
||||
__all__ = (
|
||||
"AnsibleModule",
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
import pathlib
|
||||
from typing import List
|
||||
|
||||
from ansible.module_utils.generic import SYSTEMD_NETWORK_CONFIG as SYSTEMD_PATH
|
||||
from ansible.module_utils.generic import Types
|
||||
from ansible.module_utils.module import SystemdUnitModule
|
||||
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
|
||||
except ImportError:
|
||||
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||
from plugins.module_utils.module import SystemdUnitModule
|
||||
|
||||
|
||||
class Module(SystemdUnitModule):
|
||||
"""generates an systemd-networkd link"""
|
||||
|
@ -44,7 +48,7 @@ class Module(SystemdUnitModule):
|
|||
self.get("name", "") or self.get("mac", "") or self.get("permanentmac", "")
|
||||
)
|
||||
newname = newname.replace(":", "").replace("/", "-").lower()
|
||||
self.unitfile = SYSTEMD_PATH.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:
|
||||
|
|
|
@ -2,11 +2,14 @@
|
|||
import pathlib
|
||||
from typing import List, Optional
|
||||
|
||||
from ansible.module_utils.generic import SYSTEMD_SERVICE_CONFIG as SYSTEMD_PATH
|
||||
from ansible.module_utils.generic import Types
|
||||
from ansible.module_utils.module import SystemdUnitModule
|
||||
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
|
||||
except ImportError:
|
||||
from plugins.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types
|
||||
from plugins.module_utils.module import SystemdUnitModule
|
||||
|
||||
SYSTEMD_PATH = pathlib.Path("/etc/systemd/system")
|
||||
SYSTEMD_SERVICE_CONFIG = pathlib.Path("/etc/systemd/system")
|
||||
|
||||
OPTION_MAPPING = dict(
|
||||
required_by="RequiredBy",
|
||||
|
@ -50,7 +53,7 @@ class Module(SystemdUnitModule):
|
|||
|
||||
def prepare(self):
|
||||
self.mountdir = pathlib.Path(self.params["where"])
|
||||
self.unitfile = SYSTEMD_PATH.joinpath(
|
||||
self.unitfile = SYSTEMD_SERVICE_CONFIG.joinpath(
|
||||
self.mountdir.relative_to("/").as_posix().replace("/", "-")
|
||||
).with_suffix(".mount")
|
||||
self.__unit = None
|
||||
|
|
|
@ -2,9 +2,13 @@
|
|||
import pathlib
|
||||
from typing import List, Union
|
||||
|
||||
from ansible.module_utils.generic import SYSTEMD_NETWORK_CONFIG as SYSTEMD_PATH
|
||||
from ansible.module_utils.generic import Types
|
||||
from ansible.module_utils.module import SystemdUnitModule
|
||||
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
|
||||
except ImportError:
|
||||
from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types
|
||||
from plugins.module_utils.module import SystemdUnitModule
|
||||
|
||||
|
||||
def boolconvert(b: Union[bool, str]) -> str:
|
||||
if b is True:
|
||||
|
@ -37,7 +41,7 @@ class Module(SystemdUnitModule):
|
|||
)
|
||||
|
||||
def prepare(self):
|
||||
self.unitfile = SYSTEMD_PATH.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:
|
||||
|
|
10
update_doc
10
update_doc
|
@ -3,12 +3,9 @@ import re
|
|||
import pathlib
|
||||
import importlib
|
||||
import sys
|
||||
import ansible.module_utils
|
||||
|
||||
mindocstring = "DOCUMENTATION = ''''''"
|
||||
sys.path.append("plugins/modules")
|
||||
sys.path.append(".")
|
||||
|
||||
mindocstring = "DOCUMENTATION = ''''''"
|
||||
moduledir = pathlib.Path("plugins/modules")
|
||||
regex = re.compile("DOCUMENTATION *= *r?(?P<quote>\"{3}|'{3})(---)?.*?(?P=quote)", re.MULTILINE | re.DOTALL)
|
||||
|
||||
|
@ -16,11 +13,14 @@ if __name__ == "__main__":
|
|||
for modfile in moduledir.iterdir():
|
||||
if modfile.name in ( "__init__.py", "__pycache__"):
|
||||
continue
|
||||
mod = importlib.import_module("plugins.modules."+modfile.stem)
|
||||
mod = importlib.import_module(".".join((modfile.parts[:-1])+(modfile.stem,)))
|
||||
if hasattr(mod, "Module"):
|
||||
module = mod.Module
|
||||
elif hasattr(mod, "__module_name__"):
|
||||
module = getattr(mod, mod.__module_name__)
|
||||
else:
|
||||
print("Error loading Module of File: {}. No Module or __module_name__ defined".format(modfile))
|
||||
continue
|
||||
moddoc = module.doc()
|
||||
moddata = modfile.read_text()
|
||||
match = regex.search(moddata)
|
||||
|
|
Laden…
In neuem Issue referenzieren