aboutsummaryrefslogtreecommitdiff
path: root/ansible/action_plugins
diff options
context:
space:
mode:
authorMaksim Malchuk <maksim.malchuk@gmail.com>2022-03-01 01:20:38 +0300
committerMaksim Malchuk <maksim.malchuk@gmail.com>2023-04-14 16:36:22 +0300
commit47862b56bd90c3edaab3345577901367a73cfd98 (patch)
tree50d32930aa191573dfd9b4cb4feee80744e1beb4 /ansible/action_plugins
parentb142b0ae7af478f6dee5d894e1ad1a5a3f580cf7 (diff)
downloadkolla-ansible-47862b56bd90c3edaab3345577901367a73cfd98.tar.gz
kolla-ansible-47862b56bd90c3edaab3345577901367a73cfd98.zip
Fix maximum width of the DIB Multiline-YAML
The dib_env_vars variable in the Bifrost's dib.yml file can contain the DIB_BLOCK_DEVICE_CONFIG environment variable which is always the Multiline-YAML data. By default, the format of the data is not preserved while the configuration is merged and saved for the bifrost-deploy container. This is because Ansible uses the PyYAML library which has a default 80 symbol string length limit. The official Ansible documentation [1] recommends using to_yaml or to_nice_yaml filters with width parameter. This change adds the same ability to the merge_yaml Ansible plugin. 1. https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#formatting-data-yaml-and-json The related change for the diskimage-builder to solve the issue with incorrect data provided by Kolla-Ansible is also provided: I3b74ede69eb064ad813a9108ec68a228e549e8bb Closes-Bug: #2014980 Related-Bug: #2014981 Change-Id: Id79445c0311916ac6c1beb3986e14f652ee5a63c Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
Diffstat (limited to 'ansible/action_plugins')
-rw-r--r--ansible/action_plugins/merge_yaml.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/ansible/action_plugins/merge_yaml.py b/ansible/action_plugins/merge_yaml.py
index 648109163..ea7350bf7 100644
--- a/ansible/action_plugins/merge_yaml.py
+++ b/ansible/action_plugins/merge_yaml.py
@@ -55,6 +55,14 @@ options:
default: False
required: False
type: bool
+ yaml_width:
+ description:
+ - The maximum width of the YAML document. By default, Ansible uses the
+ PyYAML library which has a default 80 symbol string length limit.
+ To change the limit, the new value can be used here.
+ default: None
+ required: False
+ type: int
author: Sean Mooney
'''
@@ -68,6 +76,7 @@ Merge multiple yaml files:
sources:
- "/tmp/default.yml"
- "/tmp/override.yml"
+ yaml_width: 131072
dest:
- "/tmp/out.yml"
'''
@@ -113,6 +122,7 @@ class ActionModule(action.ActionBase):
output = {}
sources = self._task.args.get('sources', None)
extend_lists = self._task.args.get('extend_lists', False)
+ yaml_width = self._task.args.get('yaml_width', None)
if not isinstance(sources, list):
sources = [sources]
for source in sources:
@@ -127,11 +137,13 @@ class ActionModule(action.ActionBase):
try:
result_file = os.path.join(local_tempdir, 'source')
with open(result_file, 'w') as f:
- f.write(yaml.dump(output, default_flow_style=False))
+ f.write(yaml.dump(output, default_flow_style=False,
+ width=yaml_width))
new_task = self._task.copy()
new_task.args.pop('sources', None)
new_task.args.pop('extend_lists', None)
+ new_task.args.pop('yaml_width', None)
new_task.args.update(
dict(
src=result_file