mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
refactor: use the warn module method on newer Ansible
Starting with Ansible 2.20, modules should not return the `warnings` key in the module return. Instead, modules should use the `warn` method to specify the warnings. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
This commit is contained in:
parent
3d7a3f8088
commit
1a2b1269c9
1 changed files with 7 additions and 2 deletions
|
|
@ -1851,7 +1851,7 @@ class RunEnvironmentAnsible(RunEnvironment):
|
|||
)
|
||||
|
||||
def _complete_kwargs(self, connections, kwargs, traceback_msg=None, fail=False):
|
||||
warning_logs = kwargs.get("warnings", [])
|
||||
warning_logs = kwargs.pop("warnings", [])
|
||||
debug_logs = []
|
||||
loglines = []
|
||||
for res in self._run_results:
|
||||
|
|
@ -1866,7 +1866,12 @@ class RunEnvironmentAnsible(RunEnvironment):
|
|||
warning_logs.append(log_line)
|
||||
if traceback_msg is not None:
|
||||
warning_logs.append(traceback_msg)
|
||||
kwargs["warnings"] = warning_logs
|
||||
# see if the module object has the "warn" function
|
||||
if callable(getattr(self.module, "warn", None)):
|
||||
for msg in warning_logs:
|
||||
self.module.warn(msg)
|
||||
else:
|
||||
kwargs["warnings"] = warning_logs
|
||||
stderr = "\n".join(debug_logs) + "\n"
|
||||
kwargs["stderr"] = stderr
|
||||
kwargs["_invocation"] = {"module_args": self.module.params}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue