Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
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 1527974

Summary: Problem when configuring sshd_config using ansible blockinfile on IDM clients.
Product: Red Hat Enterprise Linux 8 Reporter: David Sanz <dsanzmor>
Component: ipaAssignee: IPA Maintainers <ipa-maint>
Status: CLOSED UPSTREAM QA Contact: ipa-qe <ipa-qe>
Severity: unspecified Docs Contact:
Priority: low    
Version: 8.0CC: abokovoy, dpal, frenaud, ksiddiqu, pasik, pcech, pvoborni, rcritten, tscherf, twoerner
Target Milestone: rcKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2021-02-12 09:34:55 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description David Sanz 2017-12-20 17:05:52 UTC
Description of problem:

ipa-client-install adds following lines in the sshd_config file, before the last "Match user" line:

KerberosAuthentication no
PubkeyAuthentication yes
UsePAM yes
AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys
GSSAPIAuthentication yes
ChallengeResponseAuthentication yes
AuthorizedKeysCommandUser nobody

https://github.com/freeipa/freeipa/blob/master/ipaclient/install/client.py#L978


But... when configuring this file with ansible using blockinfile tasks, it adds some blocks like:

# BEGIN ANSIBLE MANAGED BLOCK
Match User backup
        PasswordAuthentication yes
# END ANSIBLE MANAGED BLOCK


And here is the problem, ipa-client-install is adding the parameters before the Match line, but after the ansible comment:

# BEGIN ANSIBLE MANAGED BLOCK
KerberosAuthentication no
PubkeyAuthentication yes
UsePAM yes
AuthorizedKeysCommand /usr/bin/sss_ssh_authorizedkeys
GSSAPIAuthentication yes
ChallengeResponseAuthentication yes
AuthorizedKeysCommandUser nobody

Match User backup
        PasswordAuthentication yes
# END ANSIBLE MANAGED BLOCK


Next ansible iteration will remove the lines configured by ipa-client-install, because they have been added inside the ansible managed block, and it will left only the ansible related lines:

 # BEGIN ANSIBLE MANAGED BLOCK
Match User backup
        PasswordAuthentication yes
# END ANSIBLE MANAGED BLOCK



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


How reproducible:


Steps to Reproduce:
1. Modify sshd_config file with a blockinfile ansible task
2. Register server on IdM using ipa-client-install
3. Run ansible again

Actual results:

ipa-client-install modifications are removed from the sshd_file because they are added inside the ANSIBLE MANAGED BLOCK

Expected results:

Modification should be done searching for the parameters inside the file, and modifying the default value or adding a block checking if it is being added inside a block managed by a different automation system (ansible, or any other)

Additional info:

Comment 3 Rob Crittenden 2018-01-15 18:33:42 UTC
Upstream ticket:
https://pagure.io/freeipa/issue/7367

Comment 6 Florence Blanc-Renaud 2018-10-17 16:26:36 UTC
We have a concern regarding this issue. It would not be reliable to adapt our code to detect the # BEGIN ANSIBLE MANAGED BLOCK and # END ANSIBLE MANAGED BLOCK markers because this type of marker is configurable (see https://docs.ansible.com/ansible/latest/modules/blockinfile_module.html#parameters) and could be completely different if added with a random playbook or a different automation system.

Comment 7 Florence Blanc-Renaud 2019-06-19 07:41:10 UTC
RHEL-7.7 is already near the end of a Development Phase and development is being wrapped up. I am bulk-moving to RHEL 8 the Bugs which were already triaged, but to which we did not commit (without devel_ack) and we cannot keep them even as a stretch goal for RHEL-7.7.

If you believe this particular bug should be reconsidered for 7.7, please let us know.

Comment 13 Rob Crittenden 2021-01-05 13:16:28 UTC
This should be fixed by rebase to FreeIPA 4.9.0 in RHEL 8.4 as we changed our SSH configuration to be snippet files for ssh_config and sshd_config

Comment 14 Rob Crittenden 2021-01-07 15:01:47 UTC
I misread this as configuring ssh vs sshd. It looks like the default sshd configuration does not currently support includes.

Comment 17 Petr Čech 2021-02-12 09:34:55 UTC
We are closing as upstream, because nothing to do on our side, once openssh server adds includes to sshd_config, code in FreeIPA will detect and use that.

This effort was covered with combination of:
https://pagure.io/freeipa/issue/8304
https://pagure.io/freeipa/issue/8400
https://pagure.io/freeipa/issue/8535

Comment 18 Alexander Bokovoy 2021-02-12 09:39:59 UTC
For the reference:

$ git log --oneline --grep={issue/8304,issue/8400,issue/8535}
fbd7d7718 rpmspec: ensure ipa snippet for sshd is always included
797a64b37 sshd template must be part of client package
511f5194d client install: fix broken sshd config
3cf9979ae ipa-client-install: use sshd drop-in configuration

These all ended up in the FreeIPA 4.9.0 and thus are part of RHEL 8.4. 
However, RHEL 8.4 will not have OpenSSH that supports sshd_config includes. 
Once future RHEL 8 version includes this feature, RHEL IdM will start automatically using it.