aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaksim Malchuk <maksim.malchuk@gmail.com>2023-04-01 23:55:46 +0300
committerMaksim Malchuk <maksim.malchuk@gmail.com>2023-04-02 00:33:40 +0300
commit8972241dc9736109f9d98552035e7557c366bf94 (patch)
tree258360d80ab4390afb75ff7be4be2fc408013bc4
parentda48d99eefab686293ede974f1a1997c3b894ec7 (diff)
downloadkolla-ansible-8972241dc9736109f9d98552035e7557c366bf94.tar.gz
kolla-ansible-8972241dc9736109f9d98552035e7557c366bf94.zip
Fix merge action plugins verbose output
This change fixes the output 'module_args' information of the plugins 'merge_configs' and 'merge_yaml' when Ansible is executed in maximum verbose mode. Now all the plugin options are displayed instead of standard 'copy' plugin options only. Also, this change contains fixes already applied in the Kayobe project to improve and synchronize the code of the plugins between projects. Change-Id: Ie2d9a0501fe29bfd854eb31258f282b197855948 Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
-rw-r--r--ansible/action_plugins/merge_configs.py10
-rw-r--r--[-rwxr-xr-x]ansible/action_plugins/merge_yaml.py15
2 files changed, 16 insertions, 9 deletions
diff --git a/ansible/action_plugins/merge_configs.py b/ansible/action_plugins/merge_configs.py
index 7bbf70654..a82583550 100644
--- a/ansible/action_plugins/merge_configs.py
+++ b/ansible/action_plugins/merge_configs.py
@@ -171,12 +171,12 @@ class ActionModule(action.ActionBase):
del tmp # not used
sources = self._task.args.get('sources', None)
+ whitespace = self._task.args.get('whitespace', True)
if not isinstance(sources, list):
sources = [sources]
- config = OverrideConfigParser(
- whitespace=self._task.args.get('whitespace', True))
+ config = OverrideConfigParser(whitespace=whitespace)
for source in sources:
self.read_config(source, config)
@@ -213,7 +213,11 @@ class ActionModule(action.ActionBase):
loader=self._loader,
templar=self._templar,
shared_loader_obj=self._shared_loader_obj)
- result.update(copy_action.run(task_vars=task_vars))
+ copy_result = copy_action.run(task_vars=task_vars)
+ copy_result['invocation']['module_args'].update({
+ 'src': result_file, 'sources': sources,
+ 'whitespace': whitespace})
+ result.update(copy_result)
finally:
shutil.rmtree(local_tempdir)
return result
diff --git a/ansible/action_plugins/merge_yaml.py b/ansible/action_plugins/merge_yaml.py
index c8a7182bf..648109163 100755..100644
--- a/ansible/action_plugins/merge_yaml.py
+++ b/ansible/action_plugins/merge_yaml.py
@@ -17,8 +17,7 @@ import os
import shutil
import tempfile
-from yaml import dump
-from yaml import safe_load
+import yaml
from ansible import constants
from ansible import errors as ansible_errors
@@ -81,7 +80,7 @@ class ActionModule(action.ActionBase):
def read_config(self, source):
result = None
# Only use config if present
- if os.access(source, os.R_OK):
+ if source and os.access(source, os.R_OK):
with open(source, 'r') as f:
template_data = f.read()
@@ -94,7 +93,7 @@ class ActionModule(action.ActionBase):
self._templar.environment.loader.searchpath = searchpath
template_data = self._templar.template(template_data)
- result = safe_load(template_data)
+ result = yaml.safe_load(template_data)
return result or {}
def run(self, tmp=None, task_vars=None):
@@ -128,7 +127,7 @@ class ActionModule(action.ActionBase):
try:
result_file = os.path.join(local_tempdir, 'source')
with open(result_file, 'w') as f:
- f.write(dump(output, default_flow_style=False))
+ f.write(yaml.dump(output, default_flow_style=False))
new_task = self._task.copy()
new_task.args.pop('sources', None)
@@ -147,7 +146,11 @@ class ActionModule(action.ActionBase):
loader=self._loader,
templar=self._templar,
shared_loader_obj=self._shared_loader_obj)
- result.update(copy_action.run(task_vars=task_vars))
+ copy_result = copy_action.run(task_vars=task_vars)
+ copy_result['invocation']['module_args'].update({
+ 'src': result_file, 'sources': sources,
+ 'extend_lists': extend_lists})
+ result.update(copy_result)
finally:
shutil.rmtree(local_tempdir)
return result