RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 2006230 - Replace `# {{ ansible_managed }}` with `{{ ansible_managed | comment }}`
Summary: Replace `# {{ ansible_managed }}` with `{{ ansible_managed | comment }}`
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 9
Classification: Red Hat
Component: rhel-system-roles
Version: 9.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Sergei Petrosian
QA Contact: Jakub Haruda
Gabi Fialová
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2021-09-21 09:24 UTC by Sergei Petrosian
Modified: 2022-07-11 11:38 UTC (History)
8 users (show)

Fixed In Version: rhel-system-roles-1.9.0-1.el9
Doc Type: Bug Fix
Doc Text:
.RHEL System Roles now handle multi-line `ansible_managed` comments in generated files Previously, some of the RHEL System Roles were using `# {{ ansible_managed }}` to generate some of the files. As a consequence, if a customer had a custom multi-line `ansible_managed` setting, the files would be generated incorrectly. With this fix, all of the system roles use the equivalent of `{{ ansible_managed | comment }}` when generating files so that the `ansible_managed` string is always properly commented, including multi-line `ansible_managed` values. Consequently, generated files have the correct multi-line `ansible_managed` value.
Clone Of:
: 2006231 2006233 (view as bug list)
Environment:
Last Closed: 2022-05-17 13:02:56 UTC
Type: Bug
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Github linux-system-roles bootloader pull 13 0 None Merged Use {{ ansible_managed | comment }} to fix multi-line ansible_managed 2021-09-21 14:06:15 UTC
Github linux-system-roles cockpit pull 32 0 None Merged Use {{ ansible_managed | comment }} to fix multi-line ansible_managed 2021-09-21 14:06:16 UTC
Github linux-system-roles kdump pull 89 0 None Merged Use {{ ansible_managed | comment }} to fix multi-line ansible_managed 2021-09-21 14:06:17 UTC
Github linux-system-roles kernel_settings pull 64 0 None Merged Use {{ ansible_managed | comment }} to fix multi-line ansible_managed 2021-09-21 14:06:18 UTC
Github linux-system-roles logging pull 251 0 None Merged Use {{ ansible_managed | comment }} to fix multi-line ansible_managed 2021-09-23 06:44:33 UTC
Github linux-system-roles ssh pull 21 0 None Merged Use {{ ansible_managed | comment }} to fix multi-line ansible_managed 2021-09-21 14:06:20 UTC
Github linux-system-roles template pull 71 0 None Merged Use {{ ansible_managed | comment }} to fix multi-line ansible_managed 2021-09-21 14:06:21 UTC
Github linux-system-roles timesync pull 124 0 None Merged Use {{ ansible_managed | comment }} to fix multi-line ansible_managed 2021-09-21 14:06:21 UTC
Github willshersystems ansible-sshd pull 171 0 None Merged Use {{ ansible_managed | comment }} to fix multi-line ansible_managed 2021-09-23 06:44:29 UTC
Red Hat Issue Tracker RHELPLAN-97421 0 None None None 2021-09-21 09:24:20 UTC
Red Hat Issue Tracker RHELPLAN-97717 0 None None None 2021-09-21 10:07:36 UTC
Red Hat Product Errata RHBA-2022:2443 0 None None None 2022-05-17 13:03:29 UTC

Description Sergei Petrosian 2021-09-21 09:24:21 UTC
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 14 errata-xmlrpc 2022-05-17 13:02:56 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 (new packages: rhel-system-roles), 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/RHBA-2022:2443


Note You need to log in before you can comment on or make changes to this bug.