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 The related change for Kolla-Ansible is also provided: Id79445c0311916ac6c1beb3986e14f652ee5a63c Closes-Bug: #2014981 Related-Bug: #2014980 Change-Id: I339042d9ce405f59aba936dd98df7d89a88bb41e Signed-off-by: Maksim Malchuk <maksim.malchuk@gmail.com>
This commit is contained in:
parent
e5815017b5
commit
5cf750c313
@ -9,6 +9,7 @@
|
|||||||
merge_yaml:
|
merge_yaml:
|
||||||
sources: "{{ kolla_bifrost_config_paths | product(['/kolla/config/bifrost/' ~ item]) | map('join') | list }}"
|
sources: "{{ kolla_bifrost_config_paths | product(['/kolla/config/bifrost/' ~ item]) | map('join') | list }}"
|
||||||
dest: "{{ kolla_node_custom_config_path }}/bifrost/{{ item }}"
|
dest: "{{ kolla_node_custom_config_path }}/bifrost/{{ item }}"
|
||||||
|
yaml_width: 131072
|
||||||
mode: 0640
|
mode: 0640
|
||||||
with_items:
|
with_items:
|
||||||
- bifrost.yml
|
- bifrost.yml
|
||||||
|
@ -10,7 +10,7 @@ dib_os_release: "{{ kolla_bifrost_dib_os_release }}"
|
|||||||
dib_elements: "{{ (kolla_bifrost_dib_elements + [kolla_bifrost_dib_init_element]) | join(' ') }}"
|
dib_elements: "{{ (kolla_bifrost_dib_elements + [kolla_bifrost_dib_init_element]) | join(' ') }}"
|
||||||
|
|
||||||
# DIB image environment variables.
|
# DIB image environment variables.
|
||||||
{{ {'dib_env_vars': kolla_bifrost_dib_env_vars} | to_nice_yaml }}
|
{{ {'dib_env_vars': kolla_bifrost_dib_env_vars} | to_nice_yaml(width=131072) }}
|
||||||
|
|
||||||
# List of DIB image packages.
|
# List of DIB image packages.
|
||||||
dib_packages: "{{ kolla_bifrost_dib_packages | join(',') }}"
|
dib_packages: "{{ kolla_bifrost_dib_packages | join(',') }}"
|
||||||
|
@ -59,6 +59,14 @@ options:
|
|||||||
default: False
|
default: False
|
||||||
required: False
|
required: False
|
||||||
type: bool
|
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
|
author: Sean Mooney
|
||||||
'''
|
'''
|
||||||
|
|
||||||
@ -72,6 +80,7 @@ Merge multiple yaml files:
|
|||||||
sources:
|
sources:
|
||||||
- "/tmp/default.yml"
|
- "/tmp/default.yml"
|
||||||
- "/tmp/override.yml"
|
- "/tmp/override.yml"
|
||||||
|
yaml_width: 131072
|
||||||
dest:
|
dest:
|
||||||
- "/tmp/out.yml"
|
- "/tmp/out.yml"
|
||||||
'''
|
'''
|
||||||
@ -117,6 +126,7 @@ class ActionModule(action.ActionBase):
|
|||||||
output = {}
|
output = {}
|
||||||
sources = self._task.args.get('sources', None)
|
sources = self._task.args.get('sources', None)
|
||||||
extend_lists = self._task.args.get('extend_lists', False)
|
extend_lists = self._task.args.get('extend_lists', False)
|
||||||
|
yaml_width = self._task.args.get('yaml_width', None)
|
||||||
if not isinstance(sources, list):
|
if not isinstance(sources, list):
|
||||||
sources = [sources]
|
sources = [sources]
|
||||||
for source in sources:
|
for source in sources:
|
||||||
@ -131,11 +141,13 @@ class ActionModule(action.ActionBase):
|
|||||||
try:
|
try:
|
||||||
result_file = os.path.join(local_tempdir, 'source')
|
result_file = os.path.join(local_tempdir, 'source')
|
||||||
with open(result_file, 'w') as f:
|
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 = self._task.copy()
|
||||||
new_task.args.pop('sources', None)
|
new_task.args.pop('sources', None)
|
||||||
new_task.args.pop('extend_lists', None)
|
new_task.args.pop('extend_lists', None)
|
||||||
|
new_task.args.pop('yaml_width', None)
|
||||||
new_task.args.update(
|
new_task.args.update(
|
||||||
dict(
|
dict(
|
||||||
src=result_file
|
src=result_file
|
||||||
|
Loading…
Reference in New Issue
Block a user