Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ansible/roles/kolla-openstack/tasks/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,15 @@
- name: "Ensure extra configuration files exist (strategy: concat)"
vars:
params:
content: |
{%- for path in item.sources -%}
{{ lookup('file', path) }}
{%- endfor -%}
# join() guarantees exactly one newline between sources, regardless
# of whether a source file ends with one - lookup('file') rstrips
# trailing whitespace from each source, so concatenating without an
# explicit separator can glue the last line of one file to the first
# line of the next.
content: "{{ query('file', *item.sources) | join('\n') }}\n"
dest: "{{ item.dest }}"
mode: 0640
lstrip_blocks: true
template_content: "{{ params | combine(item.params) }}"
with_items: "{{ kolla_custom_config_info.concat }}"

Expand Down
6 changes: 5 additions & 1 deletion kayobe/plugins/action/merge_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,11 @@ def read_config(self, source, config):
]

templar = self._templar.copy_with_new_env(searchpath=searchpath)
result = templar.template(template_data)

# lstrip_blocks avoids Jinja2 block tags (e.g. {% if %}) leaving
# behind leading whitespace that glues adjacent lines together.
result = templar.template(
template_data, overrides=dict(lstrip_blocks=True))
fakefile = StringIO(result)
config.parse(fakefile)
fakefile.close()
Expand Down
6 changes: 5 additions & 1 deletion kayobe/plugins/action/merge_yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ def read_config(self, source):
]

templar = self._templar.copy_with_new_env(searchpath=searchpath)
template_data = templar.template(template_data)

# lstrip_blocks avoids Jinja2 block tags (e.g. {% if %}) leaving
# behind leading whitespace that glues adjacent lines together.
template_data = templar.template(
template_data, overrides=dict(lstrip_blocks=True))
result = yaml.safe_load(template_data)
return result or {}

Expand Down