bumped the version to include the print fix
Dieser Commit ist enthalten in:
Ursprung
fe4064b3c3
Commit
8efa463b3d
|
@ -13,7 +13,7 @@ tags:
|
||||||
- systemd
|
- systemd
|
||||||
- linux
|
- linux
|
||||||
dependencies:
|
dependencies:
|
||||||
sebastian.base: ">=0.3.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
|
||||||
|
|
|
@ -0,0 +1,134 @@
|
||||||
|
#!/usr/bin/python3
|
||||||
|
import pathlib
|
||||||
|
from typing import List, Union
|
||||||
|
|
||||||
|
try:
|
||||||
|
from ansible_module.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types, modspec
|
||||||
|
from ansible_module.module_utils.module import SystemdReloadMixin, SystemdUnitModule, installable
|
||||||
|
except ImportError:
|
||||||
|
from ansible_collections.sebastian.base.plugins.module_utils.generic import SYSTEMD_SERVICE_CONFIG, Types, modspec
|
||||||
|
from ansible_collections.sebastian.base.plugins.module_utils.module import SystemdReloadMixin, SystemdUnitModule, installable
|
||||||
|
|
||||||
|
|
||||||
|
__module_name__ = "TimerModule"
|
||||||
|
|
||||||
|
|
||||||
|
@installable
|
||||||
|
class Module(SystemdUnitModule, SystemdReloadMixin): # type: ignore
|
||||||
|
"""Creates Timer units"""
|
||||||
|
|
||||||
|
name = "timer"
|
||||||
|
module_spec = modspec(
|
||||||
|
argument_spec=dict(
|
||||||
|
name=Types.str(required=True, help="Name of the unit"),
|
||||||
|
description=Types.str(help="Description of the timer"),
|
||||||
|
onactive=Types.str(help="Starts the service x seconds after this timer was activated"),
|
||||||
|
onboot=Types.str(help="Starts the service x seconds after the device was booted or the container was started"),
|
||||||
|
onstartup=Types.str(help="Starts the service x seconds after the System's/User's systemd instance was started"),
|
||||||
|
onunitactive=Types.str(help="Starts the service x seconds after the unit this timer activates was last activated"),
|
||||||
|
onunitinactive=Types.str(help="Starts the service x seconds after the unit this timer activates was last deactivated"),
|
||||||
|
oncalendar=Types.str(help="Uses an Time string to start the unit."),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def prepare(self):
|
||||||
|
self.unitfile = (SYSTEMD_SERVICE_CONFIG / self.get("name")).with_suffix(".timer")
|
||||||
|
self.__unit = None
|
||||||
|
|
||||||
|
def body(self):
|
||||||
|
section = "[Timer]\n"
|
||||||
|
return section
|
||||||
|
|
||||||
|
def unit(self) -> str:
|
||||||
|
if self.__unit is None:
|
||||||
|
self.__unit = "\n".join(
|
||||||
|
(
|
||||||
|
self.header(),
|
||||||
|
self.body(),
|
||||||
|
self.install(),
|
||||||
|
)
|
||||||
|
)
|
||||||
|
return self.__unit
|
||||||
|
|
||||||
|
|
||||||
|
DOCUMENTATION = """---
|
||||||
|
description:
|
||||||
|
- Creates Timer units
|
||||||
|
module: timer
|
||||||
|
options:
|
||||||
|
after:
|
||||||
|
default: []
|
||||||
|
description:
|
||||||
|
- list of units that this unit wants to be started after this unit
|
||||||
|
elements: str
|
||||||
|
required: false
|
||||||
|
type: list
|
||||||
|
before:
|
||||||
|
default: []
|
||||||
|
description:
|
||||||
|
- list of units that this unit needs to be started before this unit.
|
||||||
|
elements: str
|
||||||
|
required: false
|
||||||
|
type: list
|
||||||
|
description:
|
||||||
|
description:
|
||||||
|
- Description of the timer
|
||||||
|
required: false
|
||||||
|
type: str
|
||||||
|
documentation:
|
||||||
|
default: []
|
||||||
|
description:
|
||||||
|
- Paths where documentation can be found
|
||||||
|
elements: str
|
||||||
|
required: false
|
||||||
|
type: list
|
||||||
|
name:
|
||||||
|
description:
|
||||||
|
- Name of the unit
|
||||||
|
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 Timer units
|
||||||
|
"""
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
Module()()
|
Laden…
In neuem Issue referenzieren