mirror of https://github.com/ansible/ansible.git
fix incorrect ansible_managed formatting (#79129)
Ansible breaks configs if file name could be parsed as jinja template or contains `%` chars. Especially `%n`[ame%] which is a line break pattern according to [strftime (3)](https://manpages.debian.org/bullseye/manpages-dev/strftime.3.en.html)pull/81504/head^2
parent
01469c558c
commit
bd3ffbe109
@ -0,0 +1,6 @@
|
||||
---
|
||||
bugfixes:
|
||||
- template - Fix for formatting issues when a template path contains
|
||||
valid jinja/strftime pattern (especially line break one) and
|
||||
using the template path in ansible_managed
|
||||
(https://github.com/ansible/ansible/pull/79129)
|
||||
@ -0,0 +1,29 @@
|
||||
---
|
||||
- hosts: testhost
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- set_fact:
|
||||
output_dir: "{{ lookup('env', 'OUTPUT_DIR') }}"
|
||||
|
||||
- name: check strftime
|
||||
block:
|
||||
- template:
|
||||
src: "templates/%necho Onii-chan help Im stuck;exit 1%n.j2"
|
||||
dest: "{{ output_dir }}/79129-strftime.sh"
|
||||
mode: '0755'
|
||||
|
||||
- shell: "exec {{ output_dir | quote }}/79129-strftime.sh"
|
||||
|
||||
- name: check jinja template
|
||||
block:
|
||||
- template:
|
||||
src: !unsafe "templates/completely{{ 1 % 0 }} safe template.j2"
|
||||
dest: "{{ output_dir }}/79129-jinja.sh"
|
||||
mode: '0755'
|
||||
|
||||
- shell: "exec {{ output_dir | quote }}/79129-jinja.sh"
|
||||
register: result
|
||||
|
||||
- assert:
|
||||
that:
|
||||
- "'Hello' in result.stdout"
|
||||
@ -0,0 +1,3 @@
|
||||
# {{ ansible_managed }}
|
||||
echo 79129 test passed
|
||||
exit 0
|
||||
@ -0,0 +1,3 @@
|
||||
# {{ ansible_managed }}
|
||||
echo Hello
|
||||
exit 0
|
||||
Loading…
Reference in New Issue