From 1c3d89e9616c8d3b3e999998a42af78040dedd7b Mon Sep 17 00:00:00 2001 From: Sebastian Tobie Date: Sun, 16 Jul 2023 10:20:44 +0200 Subject: [PATCH] removed an missunderstanding in the docs --- plugins/module_utils/generic.py | 7 ------- plugins/module_utils/module.py | 8 ++++---- plugins/modules/link.py | 4 ++-- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/plugins/module_utils/generic.py b/plugins/module_utils/generic.py index 494d74f..6492dde 100644 --- a/plugins/module_utils/generic.py +++ b/plugins/module_utils/generic.py @@ -118,13 +118,6 @@ def modspec( ) -def format_condition(key: str, value: str) -> str: - if value[0] == "!": - value = value[1:] - key = "!" + key - return f"{key}={value}\n" - - def joindict(*items: dict) -> dict: odict = dict() for item in items: diff --git a/plugins/module_utils/module.py b/plugins/module_utils/module.py index 78da2d0..0f20c7f 100644 --- a/plugins/module_utils/module.py +++ b/plugins/module_utils/module.py @@ -5,9 +5,9 @@ from typing import Any, Callable, ClassVar, Dict, NoReturn, Optional, Type, Type import ansible.module_utils.basic as basic try: - from ansible_collections.sebastian.systemd.plugins.module_utils.generic import AnsibleParameter, Types, format_condition + from ansible_collections.sebastian.systemd.plugins.module_utils.generic import AnsibleParameter, Types except ImportError: - from plugins.module_utils.generic import AnsibleParameter, Types, format_condition + from plugins.module_utils.generic import AnsibleParameter, Types __all__ = ( @@ -250,9 +250,9 @@ class SystemdUnitModule(AnsibleModule): if self.params[param] is not None: params = self.params[param] if isinstance(params, list): - output.extend((format_condition(key, p) for p in params)) + output.extend((f"{key}={p}\n" for p in params)) else: - output.append(format_condition(key, self.params[param])) + output.append(f"{key}={self.params[param]}\n") return output def unitfile_gen(self): diff --git a/plugins/modules/link.py b/plugins/modules/link.py index 8734111..5575c6a 100644 --- a/plugins/modules/link.py +++ b/plugins/modules/link.py @@ -3,10 +3,10 @@ import pathlib from typing import List try: - from ansible_collections.sebastian.systemd.plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types, format_condition, modspec + from ansible_collections.sebastian.systemd.plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types, modspec from ansible_collections.sebastian.systemd.plugins.module_utils.module import SystemdUnitModule except ImportError: - from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types, format_condition, modspec + from plugins.module_utils.generic import SYSTEMD_NETWORK_CONFIG, Types, modspec from plugins.module_utils.module import SystemdUnitModule