Bug 2006233

Summary: Replace `# {{ ansible_managed }}` with `{{ ansible_managed | comment }}`
Product: Red Hat Enterprise Linux 7 Reporter: Sergei Petrosian <spetrosi>
Component: rhel-system-rolesAssignee: Sergei Petrosian <spetrosi>
Status: CLOSED ERRATA QA Contact: CS System Management SST QE <rhel-cs-system-management-subsystem-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.9CC: djez, dyeisley, nhosoi, rhel-cs-system-management-subsystem-qe, rmeggins, spetrosi
Target Milestone: rcKeywords: Extras, Rebase, Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 2006230 Environment:
Last Closed: 2022-06-28 14:24:49 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Sergei Petrosian 2021-09-21 09:28:40 UTC
+++ This bug was initially created as a clone of Bug #2006230 +++

Description of problem:
An upstream user requested us to replace `# {{ ansible_managed }}` with `{{ ansible_managed | comment }}` in https://github.com/linux-system-roles/timesync/issues/123.

This issue persists in the following roles:
timesync
ansible-sshd
bootloader
cockpit
kdump
kernal_settings
ssh
template

The issue is that when a user has the `ansible_managed` variable set to a multi-line entry, `# {{ ansible_managed }}` in templates expands to the ansible_managed variable with only the first line commented out.

For example, consider ansible_managed set to the following in ansible.cfg:
user@ansiblemaster:~# cat ansible.cfg|grep -A 4 ansible_managed
ansible_managed = WARNING: This file is managed by ANSIBLE.
template: {file}
modified on: %Y-%m-%d %H:%M:%S
by user: {uid}
from ansiblemaster: {host}

In this case, `# {{ ansible_managed }}` expands to the following:
root@andrea2:~# cat /etc/chrony.conf

# WARNING: This file is managed by ANSIBLE.
template: /usr/share/ansible/roles/rhel-system-roles.timesync/templates/chrony.conf.j2
modified on: 2021-09-15 13:35:58
by user: root
from ansiblemaster: ansiblemaster.mydomain.com

Because only the first line is commented out, the config file reads incorrectly and services fail to start.

The request is to replace `# {{ ansible_managed }}` with `{{ ansible_managed | comment }}` so that all lines are commented out.

Version-Release number of selected component (if applicable):
9.0


How reproducible:
When ansible_managed is set to a multi-line entry.


Steps to Reproduce:
1. In ansible.cfg, set the ansible_managed setting to a multi-line entry, e.g.:
ansible_managed = WARNING: This file is managed by ANSIBLE.
template: {file}
modified on: %Y-%m-%d %H:%M:%S
by user: {uid}
from ansiblemaster: {host}
2. Run one of the above roles.

Actual results:
Because only the first line is commented out, the config file reads incorrectly and services fail to start, hence the role fails.

Expected results:
The role runs successfully.

Comment 12 errata-xmlrpc 2022-06-28 14:24:49 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (ansible-collection-microsoft-sql bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2022:5370

Comment 13 Sergei Petrosian 2022-09-23 11:45:12 UTC
*** Bug 2129332 has been marked as a duplicate of this bug. ***