Skip to content

Commit 25ccb42

Browse files
Dennis-Qrichm
authored andcommitted
feat: search for name of domain/realm in sssd.conf; merge settings if duplicates
Feature: Search for the name of the section used in the SSSD config file for the domain/realm specific settings, as managed by `ad_dyndns_update` and `ad_integration_sssd_custom_settings`. This section is added by `realm join` and the casing of the name is determined by AD settings, so we need to search for the name using a case insensitive search. Previous versions of the role would always use a lower case realm in the section name, which may have left the SSSD config file with multiple sections for the realm. Use the new `ad_integration_sssd_merge_duplicate_sections` setting to consolidate all of the settings from the multiple sections into the chosen section. Reason: The realm/domain section in the SSSD config file is written by `realm join`, and the case is determined by AD settings, so we must do a search to find the section name to use for writting additional SSSD realm/domain settings. In addition, we need some way to clean up any previously duplicated settings from the SSSD config. Result: The ad_integration role can manage domain/realm sections in the SSSD config file correctly. Signed-off-by: Rich Megginson <rmeggins@redhat.com>
1 parent 812f918 commit 25ccb42

27 files changed

+846
-271
lines changed

.ostree/packages-testing.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
sssd-common

.sanity-ansible-ignore-2.14.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/ad_integration/templates/fake_realm.py.j2 shebang!skip

.sanity-ansible-ignore-2.15.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/ad_integration/templates/fake_realm.py.j2 shebang!skip

.sanity-ansible-ignore-2.16.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/ad_integration/templates/fake_realm.py.j2 shebang!skip

.sanity-ansible-ignore-2.17.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/ad_integration/templates/fake_realm.py.j2 shebang!skip

.sanity-ansible-ignore-2.18.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/ad_integration/templates/fake_realm.py.j2 shebang!skip

.sanity-ansible-ignore-2.19.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/ad_integration/templates/fake_realm.py.j2 shebang!skip

.sanity-ansible-ignore-2.9.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tests/ad_integration/templates/fake_realm.py.j2 shebang!skip

README.md

Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ Administrator user as the security footprint of this user is too large.
1818
See [Delegated Permissions](https://www.mankier.com/8/adcli#Delegated_Permissions)
1919
for the explicit permissions a user must have.
2020

21-
Time must be in sync with Active Directory servers. The ad_integration role will use the timesync system role for this if the user specifies `ad_integration_manage_timesync` to true and provides a value for `ad_integration_timesync_source` to use as a timesource.
21+
Time must be in sync with Active Directory servers. The ad_integration role will use the timesync system role for this if the user specifies [ad_integration_manage_timesync](#ad_integration_manage_timesync) to true and provides a value for [ad_integration_timesync_source](#ad_integration_timesync_source) to use as a timesource.
2222

23-
RHEL8 (and newer) and Fedora no longer support RC4 encryption out of the box, it is recommended to enable AES in Active Directory, if not possible then the AD-SUPPORT crypto policy must be enabled. The integration role will use the crypto_policies system role for this if the user sets the `ad_integration_manage_crypto_policies` and `ad_integration_allow_rc4_crypto` parameters to true.
23+
RHEL8 (and newer) and Fedora no longer support RC4 encryption out of the box, it is recommended to enable AES in Active Directory, if not possible then the AD-SUPPORT crypto policy must be enabled. The integration role will use the crypto_policies system role for this if the user sets the [ad_integration_manage_crypto_policies](ad_integration_manage_crypto_policies) and [ad_integration_allow_rc4_crypto](#ad_integration_allow_rc4_crypto) parameters to true.
2424

2525
The Linux system must be able to resolve default AD DNS SRV records.
2626

@@ -55,6 +55,22 @@ ansible-galaxy collection install -vv -r meta/collection-requirements.yml
5555

5656
Active Directory realm, or domain name to join
5757

58+
*NOTE* If using this role to manage realm/domain specific settings in SSSD using
59+
([ad_dyndns_update](#ad_dyndns_update) or
60+
[ad_integration_sssd_custom_settings](#ad_integration_sssd_custom_settings),
61+
older versions of the role would make the realm name lower case in the domain
62+
section name. For example, if you had specified `ad_integration_realm:
63+
EXAMPLE.COM`, then the sssd.conf section would have been `[domain/example.com]`.
64+
The role now will instead use a case-insensitive match to look for an existing
65+
section in sssd.conf, which should already exist.
66+
67+
The result of this is that you may have multiple sections for the domain in your
68+
sssd.conf. If you want to consolidate these sections into one, use
69+
[`ad_integration_sssd_merge_duplicate_sections:
70+
true`](#ad_integration_sssd_merge_duplicate_sections). See below for more
71+
information about
72+
[ad_integration_sssd_merge_duplicate_sections(#ad_integration_sssd_merge_duplicate_sections).
73+
5874
#### ad_integration_password
5975

6076
The password of the user used to authenticate with when joining the machine to the realm. Do not use cleartext - use Ansible Vault to encrypt the value.
@@ -105,13 +121,13 @@ Default: Default AD computer container
105121

106122
#### ad_integration_manage_timesync
107123

108-
If true, the ad_integration role will use fedora.linux_system_roles.timesync. Requires providing a value for `ad_integration_timesync_source` to use as a time source.
124+
If true, the ad_integration role will use fedora.linux_system_roles.timesync. Requires providing a value for [ad_integration_timesync_source](#ad_integration_timesync_source) to use as a time source.
109125

110126
Default: false
111127

112128
#### ad_integration_timesync_source
113129

114-
Hostname or IP address of time source to synchronize the system clock with. Providing this variable automatically sets `ad_integration_manage_timesync` to true.
130+
Hostname or IP address of time source to synchronize the system clock with. Providing this variable automatically sets [ad_integration_manage_timesync](#ad_integration_manage_timesync) to true.
115131

116132
#### ad_integration_manage_crypto_policies
117133

@@ -121,7 +137,7 @@ Default: false
121137

122138
#### ad_integration_allow_rc4_crypto
123139

124-
If true, the ad_integration role will set the crypto policy allowing RC4 encryption. Providing this variable automatically sets ad_integration_manage_crypto_policies to true
140+
If true, the ad_integration role will set the crypto policy allowing RC4 encryption. Providing this variable automatically sets [ad_integration_manage_crypto_policies](#ad_integration_manage_crypto_policies) to true
125141

126142
Default: false
127143

@@ -135,74 +151,78 @@ If true, the ad_integration role will use fedora.linux_system_roles.network to a
135151

136152
#### ad_integration_dns_server
137153

138-
IP address of DNS server to add to existing networking configuration. Only applicable if `ad_integration_manage_dns` is true
154+
IP address of DNS server to add to existing networking configuration. Only applicable if [ad_integration_manage_dns](#ad_integration_manage_dns) is true
139155

140156
#### ad_integration_dns_connection_name
141157

142-
The name option identifies the connection profile to be configured by the network role. It is not the name of the networking interface for which the profile applies. Only applicable if `ad_integration_manage_dns` is true
158+
The name option identifies the connection profile to be configured by the network role. It is not the name of the networking interface for which the profile applies. Only applicable if [ad_integration_manage_dns](#ad_integration_manage_dns) is true
143159

144160
#### ad_integration_dns_connection_type
145161

146-
Network connection type such as ethernet, bridge, bond...etc, the network role contains a list of possible values. Only applicable if `ad_integration_manage_dns` is true
162+
Network connection type such as ethernet, bridge, bond...etc, the network role contains a list of possible values. Only applicable if [ad_integration_manage_dns](#ad_integration_manage_dns) is true
147163

148164
#### ad_dyndns_update
149165

150166
If true, SSSD is configured to automatically update the AD DNS server with the IP address of the client.
151167

168+
*NOTE*: See the [ad_integration_realm](#ad_integration_realm), and
169+
[ad_integration_sssd_merge_duplicate_sections](#ad_integration_sssd_merge_duplicate_sections)
170+
for information about how the role writes these settings to the sssd.conf file.
171+
152172
Default: false
153173

154174
#### ad_dyndns_ttl
155175

156-
Optional. The TTL, in seconds, to apply to the client's DNS record when updating it. Only applicable if `ad_dyndns_update` is true
176+
Optional. The TTL, in seconds, to apply to the client's DNS record when updating it. Only applicable if [ad_dyndns_update](#ad_dyndns_update) is true
157177

158178
**Note:** This will override the TTL set by an administrator on the server.
159179

160180
Default: 3600
161181

162182
#### ad_dyndns_iface
163183

164-
Optional. Interface or a list of interfaces whose IP addresses should be used for dynamic DNS updates. Special value "*" implies all IPs from all interfaces should be used. Only applicable if `ad_dyndns_update` is true
184+
Optional. Interface or a list of interfaces whose IP addresses should be used for dynamic DNS updates. Special value "*" implies all IPs from all interfaces should be used. Only applicable if [ad_dyndns_update](#ad_dyndns_update) is true
165185

166186
Default: Use the IP addresses of the interface which is used for AD LDAP connection
167187

168188
#### ad_dyndns_refresh_interval
169189

170-
Optional. How often should, in seconds, periodic DNS updates be performed in addition to when the back end goes online. Only applicable if `ad_dyndns_update` is true
190+
Optional. How often should, in seconds, periodic DNS updates be performed in addition to when the back end goes online. Only applicable if [ad_dyndns_update](#ad_dyndns_update) is true
171191

172192
**Note:** lowest possible value is 60 seconds. If value less than 60 is specified sssd will assume lowest value only.
173193

174194
Default: 86400
175195

176196
#### ad_dyndns_update_ptr
177197

178-
Optional. If true, the PTR record should also be explicitly updated. Only applicable if `ad_dyndns_update` is true
198+
Optional. If true, the PTR record should also be explicitly updated. Only applicable if [ad_dyndns_update](#ad_dyndns_update) is true
179199

180200
Default: true
181201

182202
#### ad_dyndns_force_tcp
183203

184-
Optional. If true, the nsupdate utility should default to using TCP for communicating with the DNS server. Only applicable if `ad_dyndns_update` is true
204+
Optional. If true, the nsupdate utility should default to using TCP for communicating with the DNS server. Only applicable if [ad_dyndns_update](#ad_dyndns_update) is true
185205

186206
Default: false
187207

188208
#### ad_dyndns_auth
189209

190-
Optional. If true, GSS-TSIG authentication will be used for secure updates with the DNS server when updating A and AAAA records. Only applicable if `ad_dyndns_update` is true
210+
Optional. If true, GSS-TSIG authentication will be used for secure updates with the DNS server when updating A and AAAA records. Only applicable if [ad_dyndns_update](#ad_dyndns_update) is true
191211

192212
Default: true
193213

194214
#### ad_dyndns_server
195215

196-
Optional. DNS server to use when performing a DNS update when autodetection settings fail. Only applicable if `ad_dyndns_update` is true
216+
Optional. DNS server to use when performing a DNS update when autodetection settings fail. Only applicable if [ad_dyndns_update](#ad_dyndns_update) is true
197217

198218
Default: None (let nsupdate choose the server)
199219

200220
#### ad_integration_join_parameters
201221

202222
Additional parameters (as a string) supplied directly to the realm join command.
203-
Useful if some specific configuration like --user-principal=host/name@REALM or --use-ldaps is needed.
223+
Useful if some specific configuration like `--user-principal=host/name@REALM` or `--use-ldaps` is needed.
204224
See man realm for details.
205-
Example: ad_integration_join_parameters: "--user-principal host/client007@EXAMPLE.COM"
225+
Example: `ad_integration_join_parameters: "--user-principal host/client007@EXAMPLE.COM"`
206226

207227
#### ad_integration_sssd_settings
208228

@@ -228,6 +248,10 @@ ad_integration_sssd_custom_settings:
228248
value: "configuration_value"
229249
```
230250

251+
*NOTE*: See the [ad_integration_realm](#ad_integration_realm) and
252+
[ad_integration_sssd_merge_duplicate_sections](#ad_integration_sssd_merge_duplicate_sections) for information about how the
253+
role writes these settings to the sssd.conf file.
254+
231255
#### ad_integration_preserve_authselect_profile
232256

233257
This is a boolean, default is `false`. If `true`, configure realmd.conf to
@@ -241,6 +265,30 @@ By default, the role installs OS‐level packages needed for Active Directory in
241265

242266
Default: true
243267

268+
#### ad_integration_sssd_merge_duplicate_sections
269+
270+
*NOTE WELL*: This will do a [force rejoin](#ad_integration_force_rejoin) as this
271+
is the only way to clean up sssd.conf and ensure all of the settings are applied
272+
correctly after merging.
273+
274+
This is a boolean, default is `false`. Because the domain/realm section in
275+
sssd.conf is case insensitive, and you have previously used the role to manage
276+
domain/realm settings in sssd.conf, there may be multiple sections matching the
277+
domain/realm. If you want to consolidate these sections into one, use
278+
`ad_integration_sssd_merge_duplicate_sections: true`. For example, if you have
279+
a sssd.conf with both `[domain/example.com]` and `[domain/EXAMPLE.COM]`, and you
280+
want to use only the latter, then use:
281+
282+
```yaml
283+
ad_integration_realm: EXAMPLE.COM
284+
ad_integration_sssd_merge_duplicate_sections: true
285+
ad_integration_sssd_custom_settings: somesettings
286+
```
287+
288+
All of the settings from `[domain/example.com]` will be moved to
289+
`[domain/EXAMPLE.COM]`, and the section `[domain/example.com]` will be removed
290+
from sssd.conf.
291+
244292
## Example Playbook
245293

246294
The following is an example playbook to setup direct Active Directory integration with AD domain `domain.example.com`, the join will be performed with user Administrator using the vault stored password. Prior to the join, the crypto policy for AD SUPPORT with RC4 encryption allowed will be set.

defaults/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,8 @@ ad_integration_preserve_authselect_profile: false
150150

151151
# Set to false to skip the package installation task.
152152
ad_integration_manage_packages: true
153+
154+
# There may be duplicate sections for the realm in sssd.conf - if you set this
155+
# to true, then the role will consolidate the data from those duplicate sections
156+
# and remove the duplicate sections
157+
ad_integration_sssd_merge_duplicate_sections: false

0 commit comments

Comments
 (0)