Skip to content

Commit aba8a8a

Browse files
committed
Refactor domain template
1 parent 879b739 commit aba8a8a

File tree

2 files changed

+132
-205
lines changed

2 files changed

+132
-205
lines changed

manifests/domain.pp

Lines changed: 129 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -123,56 +123,135 @@
123123
Optional[String] $ldap_user_search_filter = undef,
124124
Optional[Hash] $custom_options = undef,
125125
) {
126+
# Build configuration lines in order (matching expected test output)
127+
# Debug settings
128+
$debug_level_line = $debug_level ? { undef => [], default => ["debug_level = ${debug_level}"] }
129+
$debug_timestamps_line = ["debug_timestamps = ${debug_timestamps}"]
130+
$debug_microseconds_line = ["debug_microseconds = ${debug_microseconds}"]
131+
132+
# Description and basic settings
133+
$description_line = $description ? { undef => [], default => ["description = ${description}"] }
134+
$min_id_line = ["min_id = ${min_id}"]
135+
$max_id_line = ["max_id = ${max_id}"]
136+
$enumerate_line = ["enumerate = ${enumerate}"]
137+
138+
# Subdomain and timeout settings
139+
$subdomain_enumerate_line = $subdomain_enumerate ? { false => [], default => ["subdomain_enumerate = ${subdomain_enumerate}"] }
140+
$force_timeout_line = $force_timeout ? { undef => [], default => ["force_timeout = ${force_timeout}"] }
141+
142+
# Entry cache timeout settings
143+
$entry_cache_timeout_line = $entry_cache_timeout ? { undef => [], default => ["entry_cache_timeout = ${entry_cache_timeout}"] }
144+
$entry_cache_user_timeout_line = $entry_cache_user_timeout ? { undef => [], default => ["entry_cache_user_timeout = ${entry_cache_user_timeout}"] }
145+
$entry_cache_group_timeout_line = $entry_cache_group_timeout ? { undef => [], default => ["entry_cache_group_timeout = ${entry_cache_group_timeout}"] }
146+
$entry_cache_netgroup_timeout_line = $entry_cache_netgroup_timeout ? { undef => [], default => ["entry_cache_netgroup_timeout = ${entry_cache_netgroup_timeout}"] }
147+
$entry_cache_service_timeout_line = $entry_cache_service_timeout ? { undef => [], default => ["entry_cache_service_timeout = ${entry_cache_service_timeout}"] }
148+
$entry_cache_sudo_timeout_line = $entry_cache_sudo_timeout ? { undef => [], default => ["entry_cache_sudo_timeout = ${entry_cache_sudo_timeout}"] }
149+
$entry_cache_autofs_timeout_line = $entry_cache_autofs_timeout ? { undef => [], default => ["entry_cache_autofs_timeout = ${entry_cache_autofs_timeout}"] }
150+
$entry_cache_ssh_host_timeout_line = $entry_cache_ssh_host_timeout ? { undef => [], default => ["entry_cache_ssh_host_timeout = ${entry_cache_ssh_host_timeout}"] }
151+
$refresh_expired_interval_line = $refresh_expired_interval ? { undef => [], default => ["refresh_expired_interval = ${refresh_expired_interval}"] }
152+
153+
# Cache settings
154+
$cache_credentials_line = ["cache_credentials = ${cache_credentials}"]
155+
$account_cache_expiration_line = ["account_cache_expiration = ${account_cache_expiration}"]
156+
$pwd_expiration_warning_line = $pwd_expiration_warning ? { undef => [], default => ["pwd_expiration_warning = ${pwd_expiration_warning}"] }
157+
158+
# Naming settings
159+
$use_fully_qualified_names_line = ["use_fully_qualified_names = ${use_fully_qualified_names}"]
160+
$ignore_group_members_line = ["ignore_group_members = ${ignore_group_members}"]
161+
162+
# Provider settings (id_provider is required, others optional)
163+
$id_provider_line = ["id_provider = ${id_provider}"]
164+
$auth_provider_line = $auth_provider ? { undef => [], default => ["auth_provider = ${auth_provider}"] }
165+
$access_provider_line = $access_provider ? { undef => [], default => ["access_provider = ${access_provider}"] }
166+
$chpass_provider_line = $chpass_provider ? { undef => [], default => ["chpass_provider = ${chpass_provider}"] }
167+
$sudo_provider_line = $sudo_provider ? { undef => [], default => ["sudo_provider = ${sudo_provider}"] }
168+
$selinux_provider_line = $selinux_provider ? { undef => [], default => ["selinux_provider = ${selinux_provider}"] }
169+
$subdomains_provider_line = $subdomains_provider ? { undef => [], default => ["subdomains_provider = ${subdomains_provider}"] }
170+
$autofs_provider_line = $autofs_provider ? { undef => [], default => ["autofs_provider = ${autofs_provider}"] }
171+
$hostid_provider_line = $hostid_provider ? { undef => [], default => ["hostid_provider = ${hostid_provider}"] }
172+
173+
# Pattern and formatting settings
174+
$re_expression_line = $re_expression ? { undef => [], default => ["re_expression = ${re_expression}"] }
175+
$full_name_format_line = $full_name_format ? { undef => [], default => ["full_name_format = ${full_name_format}"] }
176+
$lookup_family_order_line = $lookup_family_order ? { undef => [], default => ["lookup_family_order = ${lookup_family_order}"] }
177+
178+
# DNS settings
179+
$dns_resolver_timeout_line = ["dns_resolver_timeout = ${dns_resolver_timeout}"]
180+
$dns_discovery_domain_line = $dns_discovery_domain ? { undef => [], default => ["dns_discovery_domain = ${dns_discovery_domain}"] }
181+
182+
# Override and case sensitivity settings
183+
$override_gid_line = $override_gid ? { undef => [], default => ["override_gid = ${override_gid}"] }
184+
$case_sensitive_line = ["case_sensitive = ${case_sensitive}"]
185+
$proxy_fast_alias_line = ["proxy_fast_alias = ${proxy_fast_alias}"]
186+
187+
# Optional provider-specific settings
188+
$realmd_tags_line = $realmd_tags ? { undef => [], default => ["realmd_tags = ${realmd_tags}"] }
189+
$ldap_user_search_filter_line = $ldap_user_search_filter ? { undef => [], default => ["ldap_user_search_filter = ${ldap_user_search_filter}"] }
190+
$proxy_pam_target_line = $proxy_pam_target ? { undef => [], default => ["proxy_pam_target = ${proxy_pam_target}"] }
191+
$proxy_lib_name_line = $proxy_lib_name ? { undef => [], default => ["proxy_lib_name = ${proxy_lib_name}"] }
192+
193+
# Custom options processing
194+
$custom_options_lines = $custom_options ? {
195+
undef => [],
196+
default => $custom_options.keys.sort.map |$opt| { "${opt} = ${custom_options[$opt]}" }
197+
}
198+
199+
# Combine all lines in order
200+
$config_lines = (
201+
$debug_level_line +
202+
$debug_timestamps_line +
203+
$debug_microseconds_line +
204+
$description_line +
205+
$min_id_line +
206+
$max_id_line +
207+
$enumerate_line +
208+
$subdomain_enumerate_line +
209+
$force_timeout_line +
210+
$entry_cache_timeout_line +
211+
$entry_cache_user_timeout_line +
212+
$entry_cache_group_timeout_line +
213+
$entry_cache_netgroup_timeout_line +
214+
$entry_cache_service_timeout_line +
215+
$entry_cache_sudo_timeout_line +
216+
$entry_cache_autofs_timeout_line +
217+
$entry_cache_ssh_host_timeout_line +
218+
$refresh_expired_interval_line +
219+
$cache_credentials_line +
220+
$account_cache_expiration_line +
221+
$pwd_expiration_warning_line +
222+
$use_fully_qualified_names_line +
223+
$ignore_group_members_line +
224+
$id_provider_line +
225+
$auth_provider_line +
226+
$access_provider_line +
227+
$chpass_provider_line +
228+
$sudo_provider_line +
229+
$selinux_provider_line +
230+
$subdomains_provider_line +
231+
$autofs_provider_line +
232+
$hostid_provider_line +
233+
$re_expression_line +
234+
$full_name_format_line +
235+
$lookup_family_order_line +
236+
$dns_resolver_timeout_line +
237+
$dns_discovery_domain_line +
238+
$override_gid_line +
239+
$case_sensitive_line +
240+
$proxy_fast_alias_line +
241+
$realmd_tags_line +
242+
$ldap_user_search_filter_line +
243+
$proxy_pam_target_line +
244+
$proxy_lib_name_line +
245+
$custom_options_lines
246+
)
247+
248+
# Join all configuration lines
249+
$content = $config_lines.join("\n")
250+
126251
sssd::config::entry { "puppet_domain_${name}":
127-
content => epp(
128-
'sssd/domain.epp',
129-
{
130-
'id_provider' => $id_provider,
131-
'debug_level' => $debug_level,
132-
'debug_timestamps' => $debug_timestamps,
133-
'debug_microseconds' => $debug_microseconds,
134-
'description' => $description,
135-
'min_id' => $min_id,
136-
'max_id' => $max_id,
137-
'enumerate' => $enumerate,
138-
'subdomain_enumerate' => $subdomain_enumerate,
139-
'force_timeout' => $force_timeout,
140-
'entry_cache_timeout' => $entry_cache_timeout,
141-
'entry_cache_user_timeout' => $entry_cache_user_timeout,
142-
'entry_cache_group_timeout' => $entry_cache_group_timeout,
143-
'entry_cache_netgroup_timeout' => $entry_cache_netgroup_timeout,
144-
'entry_cache_service_timeout' => $entry_cache_service_timeout,
145-
'entry_cache_sudo_timeout' => $entry_cache_sudo_timeout,
146-
'entry_cache_autofs_timeout' => $entry_cache_autofs_timeout,
147-
'entry_cache_ssh_host_timeout' => $entry_cache_ssh_host_timeout,
148-
'refresh_expired_interval' => $refresh_expired_interval,
149-
'cache_credentials' => $cache_credentials,
150-
'account_cache_expiration' => $account_cache_expiration,
151-
'pwd_expiration_warning' => $pwd_expiration_warning,
152-
'use_fully_qualified_names' => $use_fully_qualified_names,
153-
'ignore_group_members' => $ignore_group_members,
154-
'access_provider' => $access_provider,
155-
'auth_provider' => $auth_provider,
156-
'chpass_provider' => $chpass_provider,
157-
'sudo_provider' => $sudo_provider,
158-
'selinux_provider' => $selinux_provider,
159-
'subdomains_provider' => $subdomains_provider,
160-
'autofs_provider' => $autofs_provider,
161-
'hostid_provider' => $hostid_provider,
162-
're_expression' => $re_expression,
163-
'full_name_format' => $full_name_format,
164-
'lookup_family_order' => $lookup_family_order,
165-
'dns_resolver_timeout' => $dns_resolver_timeout,
166-
'dns_discovery_domain' => $dns_discovery_domain,
167-
'override_gid' => $override_gid,
168-
'case_sensitive' => $case_sensitive,
169-
'proxy_fast_alias' => $proxy_fast_alias,
170-
'realmd_tags' => $realmd_tags,
171-
'proxy_pam_target' => $proxy_pam_target,
172-
'proxy_lib_name' => $proxy_lib_name,
173-
'ldap_user_search_filter' => $ldap_user_search_filter,
174-
'custom_options' => $custom_options,
175-
},
176-
),
252+
content => epp('sssd/domain.epp', {
253+
'name' => $name,
254+
'content' => $content,
255+
}),
177256
}
178257
}

templates/domain.epp

Lines changed: 3 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -1,159 +1,7 @@
11
<% |
2-
Sssd::IdProvider $id_provider,
3-
Optional[Sssd::DebugLevel] $debug_level,
4-
Boolean $debug_timestamps,
5-
Boolean $debug_microseconds,
6-
Optional[String] $description,
7-
Integer[0] $min_id,
8-
Integer[0] $max_id,
9-
Boolean $enumerate,
10-
Boolean $subdomain_enumerate,
11-
Optional[Integer] $force_timeout,
12-
Optional[Integer] $entry_cache_timeout,
13-
Optional[Integer] $entry_cache_user_timeout,
14-
Optional[Integer] $entry_cache_group_timeout,
15-
Optional[Integer] $entry_cache_netgroup_timeout,
16-
Optional[Integer] $entry_cache_service_timeout,
17-
Optional[Integer] $entry_cache_sudo_timeout,
18-
Optional[Integer] $entry_cache_autofs_timeout,
19-
Optional[Integer] $entry_cache_ssh_host_timeout,
20-
Optional[Integer] $refresh_expired_interval,
21-
Boolean $cache_credentials,
22-
Integer[0] $account_cache_expiration,
23-
Optional[Integer[0]] $pwd_expiration_warning,
24-
Boolean $use_fully_qualified_names,
25-
Boolean $ignore_group_members,
26-
Optional[Sssd::AccessProvider] $access_provider,
27-
Optional[Sssd::AuthProvider] $auth_provider,
28-
Optional[Sssd::ChpassProvider] $chpass_provider,
29-
Optional[Enum['ldap', 'ipa','ad','none']] $sudo_provider,
30-
Optional[Enum['ipa', 'none']] $selinux_provider,
31-
Optional[Enum['ipa', 'ad','none']] $subdomains_provider,
32-
Optional[Enum['ad', 'ldap', 'ipa','none']] $autofs_provider,
33-
Optional[Enum['ipa', 'none']] $hostid_provider,
34-
Optional[String] $re_expression,
35-
Optional[String] $full_name_format,
36-
Optional[String] $lookup_family_order,
37-
Integer[0] $dns_resolver_timeout,
38-
Optional[String] $dns_discovery_domain,
39-
Optional[String] $override_gid,
40-
Variant[Boolean,Enum['preserving']] $case_sensitive,
41-
Boolean $proxy_fast_alias,
42-
Optional[String] $realmd_tags,
43-
Optional[String] $proxy_pam_target,
44-
Optional[String] $proxy_lib_name,
45-
Optional[String] $ldap_user_search_filter,
46-
Optional[Hash] $custom_options,
2+
String[1] $name,
3+
String[1] $content,
474
| -%>
48-
495
# sssd::domain <%= $name %>
506
[domain/<%= $name %>]
51-
<% if $debug_level { -%>
52-
debug_level = <%= $debug_level %>
53-
<% } -%>
54-
debug_timestamps = <%= $debug_timestamps %>
55-
debug_microseconds = <%= $debug_microseconds %>
56-
<% if $description { -%>
57-
description = <%= $description %>
58-
<% } -%>
59-
min_id = <%= $min_id %>
60-
max_id = <%= $max_id %>
61-
enumerate = <%= $enumerate %>
62-
<% if $subdomain_enumerate { -%>
63-
subdomain_enumerate = <%= $subdomain_enumerate %>
64-
<% } -%>
65-
<% if $force_timeout { -%>
66-
force_timeout = <%= $force_timeout %>
67-
<% } -%>
68-
<% if $entry_cache_timeout { -%>
69-
entry_cache_timeout = <%= $entry_cache_timeout %>
70-
<% } -%>
71-
<% if $entry_cache_user_timeout { -%>
72-
entry_cache_user_timeout = <%= $entry_cache_user_timeout %>
73-
<% } -%>
74-
<% if $entry_cache_group_timeout { -%>
75-
entry_cache_group_timeout = <%= $entry_cache_group_timeout %>
76-
<% } -%>
77-
<% if $entry_cache_netgroup_timeout { -%>
78-
entry_cache_netgroup_timeout = <%= $entry_cache_netgroup_timeout %>
79-
<% } -%>
80-
<% if $entry_cache_service_timeout { -%>
81-
entry_cache_service_timeout = <%= $entry_cache_service_timeout %>
82-
<% } -%>
83-
<% if $entry_cache_sudo_timeout { -%>
84-
entry_cache_sudo_timeout = <%= $entry_cache_sudo_timeout %>
85-
<% } -%>
86-
<% if $entry_cache_autofs_timeout { -%>
87-
entry_cache_autofs_timeout = <%= $entry_cache_autofs_timeout %>
88-
<% } -%>
89-
<% if $entry_cache_ssh_host_timeout { -%>
90-
entry_cache_ssh_host_timeout = <%= $entry_cache_ssh_host_timeout %>
91-
<% } -%>
92-
<% if $refresh_expired_interval { -%>
93-
refresh_expired_interval = <%= $refresh_expired_interval %>
94-
<% } -%>
95-
cache_credentials = <%= $cache_credentials %>
96-
account_cache_expiration = <%= $account_cache_expiration %>
97-
<% if $pwd_expiration_warning { -%>
98-
pwd_expiration_warning = <%= $pwd_expiration_warning %>
99-
<% } -%>
100-
use_fully_qualified_names = <%= $use_fully_qualified_names %>
101-
ignore_group_members = <%= $ignore_group_members %>
102-
id_provider = <%= $id_provider %>
103-
<% if $auth_provider { -%>
104-
auth_provider = <%= $auth_provider %>
105-
<% } -%>
106-
<% if $access_provider { -%>
107-
access_provider = <%= $access_provider %>
108-
<% } -%>
109-
<% if $chpass_provider { -%>
110-
chpass_provider = <%= $chpass_provider %>
111-
<% } -%>
112-
<% if $sudo_provider { -%>
113-
sudo_provider = <%= $sudo_provider %>
114-
<% } -%>
115-
<% if $selinux_provider { -%>
116-
selinux_provider = <%= $selinux_provider %>
117-
<% } -%>
118-
<% if $subdomains_provider { -%>
119-
subdomains_provider = <%= $subdomains_provider %>
120-
<% } -%>
121-
<% if $autofs_provider { -%>
122-
autofs_provider = <%= $autofs_provider %>
123-
<% } -%>
124-
<% if $hostid_provider { -%>
125-
hostid_provider = <%= $hostid_provider %>
126-
<% } -%>
127-
<% if $re_expression { -%>
128-
re_expression = <%= $re_expression %>
129-
<% } -%>
130-
<% if $full_name_format { -%>
131-
full_name_format = <%= $full_name_format %>
132-
<% } -%>
133-
<% if $lookup_family_order { -%>
134-
lookup_family_order = <%= $lookup_family_order %>
135-
<% } -%>
136-
dns_resolver_timeout = <%= $dns_resolver_timeout %>
137-
<% if $dns_discovery_domain { -%>
138-
dns_discovery_domain = <%= $dns_discovery_domain %>
139-
<% } -%>
140-
<% if $override_gid { -%>
141-
override_gid = <%= $override_gid %>
142-
<% } -%>
143-
case_sensitive = <%= $case_sensitive %>
144-
proxy_fast_alias = <%= $proxy_fast_alias %>
145-
<% if $realmd_tags { -%>
146-
realmd_tags = <%= $realmd_tags %>
147-
<% } -%>
148-
<% if $ldap_user_search_filter { -%>
149-
ldap_user_search_filter = <%= $ldap_user_search_filter %>
150-
<% } -%>
151-
<% if $proxy_pam_target { -%>
152-
proxy_pam_target = <%= $proxy_pam_target %>
153-
<% } -%>
154-
<% if $proxy_lib_name { -%>
155-
proxy_lib_name = <%= $proxy_lib_name %>
156-
<% } -%>
157-
<% $custom_options.lest || { {} }.each |$opt, $value| { -%>
158-
<%= $opt %> = <%= $value %>
159-
<% } -%>
7+
<%= $content %>

0 commit comments

Comments
 (0)