From 1da65334e2f614165a4d541af89210b5e426b071 Mon Sep 17 00:00:00 2001 From: Sebastian Tobie Date: Tue, 12 Mar 2024 21:18:09 +0100 Subject: [PATCH] added an default display --- changelogs/fragments/display.yml | 2 ++ plugins/module_utils/module.py | 4 ++++ 2 files changed, 6 insertions(+) create mode 100644 changelogs/fragments/display.yml diff --git a/changelogs/fragments/display.yml b/changelogs/fragments/display.yml new file mode 100644 index 0000000..da449c1 --- /dev/null +++ b/changelogs/fragments/display.yml @@ -0,0 +1,2 @@ +--- +release_summary: added an default Display to the module diff --git a/plugins/module_utils/module.py b/plugins/module_utils/module.py index 48e4326..a2a4bc1 100644 --- a/plugins/module_utils/module.py +++ b/plugins/module_utils/module.py @@ -1,6 +1,7 @@ import pathlib from copy import deepcopy from typing import Any, Callable, ClassVar, Dict, NoReturn, Optional, Type, TypeVar, Union, overload +from ansible.utils.display import Display import ansible.module_utils.basic as basic @@ -55,6 +56,8 @@ class AnsibleModule(object): module_spec: ClassVar[dict] #: This is set by classes that define common things for their subclasses, like behaviour of the run and check methods. This is used by `SystemdUnitModule` _common_args: ClassVar[dict[str, Any]] = dict() + #: For log messages + display: Display @property def params(self) -> Dict[str, Any]: @@ -70,6 +73,7 @@ class AnsibleModule(object): specs["argument_spec"].update(modspec["argument_spec"]) del modspec["argument_spec"] specs.update(modspec) + self.display = Display() self.module = basic.AnsibleModule(**specs) self.tmpdir = pathlib.Path(self.module.tmpdir)