From 9de06a6c982834d05ed7326949a41c3071026ce0 Mon Sep 17 00:00:00 2001 From: Sebastian Tobie Date: Fri, 21 Apr 2023 00:22:27 +0200 Subject: [PATCH] added target unit type --- plugins/modules/target.py | 118 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 plugins/modules/target.py diff --git a/plugins/modules/target.py b/plugins/modules/target.py new file mode 100644 index 0000000..d72795d --- /dev/null +++ b/plugins/modules/target.py @@ -0,0 +1,118 @@ +#!/usr/bin/python3 +import pathlib +from typing import List, Union + +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, installable + + +@installable +class Module(SystemdUnitModule): + """Creates Target units""" + + name = "target" + module_spec = dict( + argument_spec=dict( + description=Types.str(required=True), + name=Types.str(required=True), + allow_isolate=Types.bool(default=False), + ), + ) + + def unit(self) -> str: + if self.__unit is None: + self.__unit = "\n".join( + ( + self.header(), + self.mount(), + self.install(), + ) + ) + return self.__unit + + +DOCUMENTATION = """--- +description: +- Creates Target units +module: target +options: + after: + default: [] + description: + - list of units that this unit wants to be started after this unit + elements: str + required: false + type: list + allow_isolate: + default: false + required: false + type: bool + before: + default: [] + description: + - list of units that this unit needs to be started before this unit. + elements: str + required: false + type: list + description: + required: true + type: str + documentation: + default: [] + description: + - Paths where documentation can be found + elements: str + required: false + type: list + name: + required: true + type: str + partof: + default: [] + description: + - list of units that this unit is part of. + - If the restart this unit does it too, but if this restarts it does not affect + the other units. + elements: str + required: false + type: list + required_by: + default: [] + description: + - systemd units that require this mount + elements: str + required: false + type: list + requires: + default: [] + description: + - list of units that this unit requires. If it fails or can't be started this + unit fails. without before/after this is started at the same time + elements: str + required: false + type: list + wanted_by: + default: [] + description: + - systemd units that want the mount, but not explicitly require it. Commonly used + for target if not service explicitly require it. + elements: str + required: false + type: list + wants: + default: [] + description: + - list of units that this unit wants. If it fails or can't be started it does + not affect this unit + elements: str + required: false + type: list +short_description: Creates Target units +""" + +if __name__ == "__main__": + Module()()