Skip to content

Commit 1d215ea

Browse files
committed
Refactor ipa and nss templates
1 parent aba8a8a commit 1d215ea

File tree

4 files changed

+157
-227
lines changed

4 files changed

+157
-227
lines changed

manifests/provider/ipa.pp

Lines changed: 85 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -75,48 +75,93 @@
7575
Array[String] $ldap_tls_cipher_suite = ['HIGH','-SSLv2'],
7676
Boolean $use_service_discovery = true,
7777
) {
78-
if $use_service_discovery {
79-
$_ipa_server = ['_srv_'] + $ipa_server
80-
}
81-
else {
82-
$_ipa_server = $ipa_server
78+
# Build configuration lines in order (matching expected test output)
79+
# IPA domain configuration (required)
80+
$ipa_domain_line = ["ipa_domain = ${ipa_domain}"]
81+
82+
# IPA server configuration with service discovery logic
83+
$ipa_server_line = $use_service_discovery ? {
84+
true => ["ipa_server = _srv_,${ipa_server.join(',')}"],
85+
false => ["ipa_server = ${ipa_server.join(',')}"]
8386
}
8487

88+
# IPA backup server configuration (optional)
89+
$ipa_backup_server_line = $ipa_backup_server ? { undef => [], default => ["ipa_backup_server = ${ipa_backup_server.join(',')}"] }
90+
91+
# IPA boolean settings (required)
92+
$ipa_enable_dns_sites_line = ["ipa_enable_dns_sites = ${ipa_enable_dns_sites}"]
93+
$ipa_hostname_line = ["ipa_hostname = ${ipa_hostname}"]
94+
$ipa_server_mode_line = ["ipa_server_mode = ${ipa_server_mode}"]
95+
96+
# Dynamic DNS settings
97+
$dyndns_auth_line = ["dyndns_auth = ${dyndns_auth}"]
98+
$dyndns_force_tcp_line = $dyndns_force_tcp ? { undef => [], default => ["dyndns_force_tcp = ${dyndns_force_tcp}"] }
99+
$dyndns_iface_line = $dyndns_iface ? { undef => [], default => ["dyndns_iface = ${dyndns_iface.join(',')}"] }
100+
$dyndns_refresh_interval_line = $dyndns_refresh_interval ? { undef => [], default => ["dyndns_refresh_interval = ${dyndns_refresh_interval}"] }
101+
$dyndns_server_line = $dyndns_server ? { undef => [], default => ["dyndns_server = ${dyndns_server}"] }
102+
$dyndns_ttl_line = $dyndns_ttl ? { undef => [], default => ["dyndns_ttl = ${dyndns_ttl}"] }
103+
$dyndns_update_line = ["dyndns_update = ${dyndns_update}"]
104+
$dyndns_update_ptr_line = $dyndns_update_ptr ? { undef => [], default => ["dyndns_update_ptr = ${dyndns_update_ptr}"] }
105+
106+
# IPA-specific optional settings
107+
$ipa_automount_location_line = $ipa_automount_location ? { undef => [], default => ["ipa_automount_location = ${ipa_automount_location}"] }
108+
$ipa_hbac_refresh_line = $ipa_hbac_refresh ? { undef => [], default => ["ipa_hbac_refresh = ${ipa_hbac_refresh}"] }
109+
$ipa_hbac_search_base_line = $ipa_hbac_search_base ? { undef => [], default => ["ipa_hbac_search_base = ${ipa_hbac_search_base}"] }
110+
$ipa_hbac_selinux_line = $ipa_hbac_selinux ? { undef => [], default => ["ipa_hbac_selinux = ${ipa_hbac_selinux}"] }
111+
$ipa_host_search_base_line = $ipa_host_search_base ? { undef => [], default => ["ipa_host_search_base = ${ipa_host_search_base}"] }
112+
$ipa_master_domains_search_base_line = $ipa_master_domains_search_base ? { undef => [], default => ["ipa_master_domains_search_base = ${ipa_master_domains_search_base}"] }
113+
$ipa_selinux_search_base_line = $ipa_selinux_search_base ? { undef => [], default => ["ipa_selinux_search_base = ${ipa_selinux_search_base}"] }
114+
$ipa_subdomains_search_base_line = $ipa_subdomains_search_base ? { undef => [], default => ["ipa_subdomains_search_base = ${ipa_subdomains_search_base}"] }
115+
$ipa_views_search_base_line = $ipa_views_search_base ? { undef => [], default => ["ipa_views_search_base = ${ipa_views_search_base}"] }
116+
117+
# Kerberos settings
118+
$krb5_confd_path_line = $krb5_confd_path ? { undef => [], default => ["krb5_confd_path = ${krb5_confd_path}"] }
119+
$krb5_realm_line = $krb5_realm ? { undef => [], default => ["krb5_realm = ${krb5_realm}"] }
120+
$krb5_store_password_if_offline_line = ["krb5_store_password_if_offline = ${krb5_store_password_if_offline}"]
121+
122+
# LDAP TLS settings (required)
123+
$ldap_tls_cacert_line = ["ldap_tls_cacert = ${ldap_tls_cacert}"]
124+
$ldap_tls_cipher_suite_line = ["ldap_tls_cipher_suite = ${ldap_tls_cipher_suite.join(':')}"]
125+
126+
# Combine all lines in order
127+
$config_lines = (
128+
$ipa_domain_line +
129+
$ipa_server_line +
130+
$ipa_backup_server_line +
131+
$ipa_enable_dns_sites_line +
132+
$ipa_hostname_line +
133+
$ipa_server_mode_line +
134+
$dyndns_auth_line +
135+
$dyndns_force_tcp_line +
136+
$dyndns_iface_line +
137+
$dyndns_refresh_interval_line +
138+
$dyndns_server_line +
139+
$dyndns_ttl_line +
140+
$dyndns_update_line +
141+
$dyndns_update_ptr_line +
142+
$ipa_automount_location_line +
143+
$ipa_hbac_refresh_line +
144+
$ipa_hbac_search_base_line +
145+
$ipa_hbac_selinux_line +
146+
$ipa_host_search_base_line +
147+
$ipa_master_domains_search_base_line +
148+
$ipa_selinux_search_base_line +
149+
$ipa_subdomains_search_base_line +
150+
$ipa_views_search_base_line +
151+
$krb5_confd_path_line +
152+
$krb5_realm_line +
153+
$krb5_store_password_if_offline_line +
154+
$ldap_tls_cacert_line +
155+
$ldap_tls_cipher_suite_line
156+
)
157+
158+
# Join all configuration lines
159+
$content = $config_lines.join("\n")
160+
85161
sssd::config::entry { "puppet_provider_${name}_ipa":
86-
content => epp(
87-
"${module_name}/provider/ipa.epp",
88-
{
89-
'title' => $title,
90-
'ipa_domain' => $ipa_domain,
91-
'ipa_server' => $ipa_server,
92-
'ipa_backup_server' => $ipa_backup_server,
93-
'ipa_enable_dns_sites' => $ipa_enable_dns_sites,
94-
'ipa_hostname' => $ipa_hostname,
95-
'ipa_server_mode' => $ipa_server_mode,
96-
'dyndns_auth' => $dyndns_auth,
97-
'dyndns_force_tcp' => $dyndns_force_tcp,
98-
'dyndns_iface' => $dyndns_iface,
99-
'dyndns_refresh_interval' => $dyndns_refresh_interval,
100-
'dyndns_server' => $dyndns_server,
101-
'dyndns_ttl' => $dyndns_ttl,
102-
'dyndns_update' => $dyndns_update,
103-
'dyndns_update_ptr' => $dyndns_update_ptr,
104-
'ipa_automount_location' => $ipa_automount_location,
105-
'ipa_hbac_refresh' => $ipa_hbac_refresh,
106-
'ipa_hbac_search_base' => $ipa_hbac_search_base,
107-
'ipa_hbac_selinux' => $ipa_hbac_selinux,
108-
'ipa_host_search_base' => $ipa_host_search_base,
109-
'ipa_master_domains_search_base' => $ipa_master_domains_search_base,
110-
'ipa_selinux_search_base' => $ipa_selinux_search_base,
111-
'ipa_subdomains_search_base' => $ipa_subdomains_search_base,
112-
'ipa_views_search_base' => $ipa_views_search_base,
113-
'krb5_confd_path' => $krb5_confd_path,
114-
'krb5_realm' => $krb5_realm,
115-
'krb5_store_password_if_offline' => $krb5_store_password_if_offline,
116-
'ldap_tls_cacert' => $ldap_tls_cacert,
117-
'ldap_tls_cipher_suite' => $ldap_tls_cipher_suite,
118-
'use_service_discovery' => $use_service_discovery,
119-
}
120-
),
162+
content => epp("${module_name}/provider/ipa.epp", {
163+
'title' => $title,
164+
'content' => $content,
165+
}),
121166
}
122167
}

manifests/service/nss.pp

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
Optional[Hash] $custom_options = undef,
6363
) {
6464
if $custom_options {
65+
# Use custom options template for backwards compatibility
6566
$_content = epp(
6667
"${module_name}/service/custom_options.epp",
6768
{
@@ -70,32 +71,73 @@
7071
},
7172
)
7273
} else {
73-
$_content = epp(
74-
"${module_name}/service/nss.epp",
75-
{
76-
'description' => $description,
77-
'debug_level' => $debug_level,
78-
'debug_timestamps' => $debug_timestamps,
79-
'debug_microseconds' => $debug_microseconds,
80-
'reconnection_retries' => $reconnection_retries,
81-
'fd_limit' => $fd_limit,
82-
'command' => $command,
83-
'enum_cache_timeout' => $enum_cache_timeout,
84-
'entry_cache_nowait_percentage' => $entry_cache_nowait_percentage,
85-
'entry_negative_timeout' => $entry_negative_timeout,
86-
'filter_users' => $filter_users,
87-
'filter_groups' => $filter_groups,
88-
'filter_users_in_groups' => $filter_users_in_groups,
89-
'override_homedir' => $override_homedir,
90-
'fallback_homedir' => $fallback_homedir,
91-
'override_shell' => $override_shell,
92-
'vetoed_shells' => $vetoed_shells,
93-
'default_shell' => $default_shell,
94-
'get_domains_timeout' => $get_domains_timeout,
95-
'memcache_timeout' => $memcache_timeout,
96-
'user_attributes' => $user_attributes,
97-
},
74+
# Build configuration lines in order (matching expected test output)
75+
# Debug settings
76+
$description_line = $description ? { undef => [], default => ["description = ${description}"] }
77+
$debug_level_line = $debug_level ? { undef => [], default => ["debug_level = ${debug_level}"] }
78+
$debug_timestamps_line = ["debug_timestamps = ${debug_timestamps}"]
79+
$debug_microseconds_line = ["debug_microseconds = ${debug_microseconds}"]
80+
81+
# Connection settings
82+
$reconnection_retries_line = ["reconnection_retries = ${reconnection_retries}"]
83+
$fd_limit_line = $fd_limit ? { undef => [], default => ["fd_limit = ${fd_limit}"] }
84+
$command_line = $command ? { undef => [], default => ["command = ${command}"] }
85+
86+
# Cache settings
87+
$enum_cache_timeout_line = ["enum_cache_timeout = ${enum_cache_timeout}"]
88+
$entry_cache_nowait_percentage_line = ["entry_cache_nowait_percentage = ${entry_cache_nowait_percentage}"]
89+
$entry_negative_timeout_line = ["entry_negative_timeout = ${entry_negative_timeout}"]
90+
91+
# Filter settings
92+
$filter_users_line = ["filter_users = ${filter_users}"]
93+
$filter_groups_line = ["filter_groups = ${filter_groups}"]
94+
$filter_users_in_groups_line = ["filter_users_in_groups = ${filter_users_in_groups}"]
95+
96+
# Home directory settings
97+
$override_homedir_line = $override_homedir ? { undef => [], default => ["override_homedir = ${override_homedir}"] }
98+
$fallback_homedir_line = $fallback_homedir ? { undef => [], default => ["fallback_homedir = ${fallback_homedir}"] }
99+
100+
# Shell settings
101+
$override_shell_line = $override_shell ? { undef => [], default => ["override_shell = ${override_shell}"] }
102+
$vetoed_shells_line = $vetoed_shells ? { undef => [], default => ["vetoed_shells = ${vetoed_shells}"] }
103+
$default_shell_line = $default_shell ? { undef => [], default => ["default_shell = ${default_shell}"] }
104+
105+
# Timeout and attribute settings
106+
$get_domains_timeout_line = $get_domains_timeout ? { undef => [], default => ["get_domains_timeout = ${get_domains_timeout}"] }
107+
$memcache_timeout_line = $memcache_timeout ? { undef => [], default => ["memcache_timeout = ${memcache_timeout}"] }
108+
$user_attributes_line = $user_attributes ? { undef => [], default => ["user_attributes = ${user_attributes}"] }
109+
110+
# Combine all lines in order
111+
$config_lines = (
112+
$description_line +
113+
$debug_level_line +
114+
$debug_timestamps_line +
115+
$debug_microseconds_line +
116+
$reconnection_retries_line +
117+
$fd_limit_line +
118+
$command_line +
119+
$enum_cache_timeout_line +
120+
$entry_cache_nowait_percentage_line +
121+
$entry_negative_timeout_line +
122+
$filter_users_line +
123+
$filter_groups_line +
124+
$filter_users_in_groups_line +
125+
$override_homedir_line +
126+
$fallback_homedir_line +
127+
$override_shell_line +
128+
$vetoed_shells_line +
129+
$default_shell_line +
130+
$get_domains_timeout_line +
131+
$memcache_timeout_line +
132+
$user_attributes_line
98133
)
134+
135+
# Join all configuration lines
136+
$content = $config_lines.join("\n")
137+
138+
$_content = epp("${module_name}/service/nss.epp", {
139+
'content' => $content,
140+
})
99141
}
100142

101143
sssd::config::entry { 'puppet_service_nss':

templates/provider/ipa.epp

Lines changed: 3 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,102 +1,7 @@
11
<% |
2-
String $title,
3-
String[1] $ipa_domain,
4-
Array[Simplib::Host] $ipa_server,
5-
Optional[Array[Simplib::Host]] $ipa_backup_server,
6-
Boolean $ipa_enable_dns_sites,
7-
Simplib::Hostname $ipa_hostname,
8-
Boolean $ipa_server_mode,
9-
Enum['none','GSS-TSIG'] $dyndns_auth,
10-
Optional[Boolean] $dyndns_force_tcp,
11-
Optional[Array[String[1]]] $dyndns_iface,
12-
Optional[Integer[0]] $dyndns_refresh_interval,
13-
Optional[Simplib::Host] $dyndns_server,
14-
Optional[Integer[0]] $dyndns_ttl,
15-
Boolean $dyndns_update,
16-
Optional[Boolean] $dyndns_update_ptr,
17-
Optional[String] $ipa_automount_location,
18-
Optional[Integer[0]] $ipa_hbac_refresh,
19-
Optional[String] $ipa_hbac_search_base,
20-
Optional[Integer[0]] $ipa_hbac_selinux,
21-
Optional[String] $ipa_host_search_base,
22-
Optional[String] $ipa_master_domains_search_base,
23-
Optional[String] $ipa_selinux_search_base,
24-
Optional[String] $ipa_subdomains_search_base,
25-
Optional[String] $ipa_views_search_base,
26-
Optional[Stdlib::AbsolutePath] $krb5_confd_path,
27-
Optional[String] $krb5_realm,
28-
Boolean $krb5_store_password_if_offline,
29-
Stdlib::AbsolutePath $ldap_tls_cacert,
30-
Array[String] $ldap_tls_cipher_suite,
31-
Boolean $use_service_discovery,
2+
String[1] $title,
3+
String[1] $content,
324
| -%>
335
[domain/<%= $title %>]
346
# sssd::provider::ipa
35-
ipa_domain = <%= $ipa_domain %>
36-
<% if $use_service_discovery { -%>
37-
ipa_server = _srv_,<%= $ipa_server.join(',') %>
38-
<% } else { -%>
39-
ipa_server = <%= $ipa_server.join(',') %>
40-
<% } -%>
41-
<% unless $ipa_backup_server =~ Undef { -%>
42-
ipa_backup_server = <%= $ipa_backup_server.join(',') %>
43-
<% } -%>
44-
ipa_enable_dns_sites = <%= $ipa_enable_dns_sites %>
45-
ipa_hostname = <%= $ipa_hostname %>
46-
ipa_server_mode = <%= $ipa_server_mode %>
47-
dyndns_auth = <%= $dyndns_auth %>
48-
<% unless $dyndns_force_tcp =~ Undef { -%>
49-
dyndns_force_tcp = <%= $dyndns_force_tcp %>
50-
<% } -%>
51-
<% unless $dyndns_iface =~ Undef { -%>
52-
dyndns_iface = <%= $dyndns_iface.join(',') %>
53-
<% } -%>
54-
<% unless $dyndns_refresh_interval =~ Undef { -%>
55-
dyndns_refresh_interval = <%= $dyndns_refresh_interval %>
56-
<% } -%>
57-
<% unless $dyndns_server =~ Undef { -%>
58-
dyndns_server = <%= $dyndns_server %>
59-
<% } -%>
60-
<% unless $dyndns_ttl =~ Undef { -%>
61-
dyndns_ttl = <%= $dyndns_ttl %>
62-
<% } -%>
63-
dyndns_update = <%= $dyndns_update %>
64-
<% unless $dyndns_update_ptr =~ Undef { -%>
65-
dyndns_update_ptr = <%= $dyndns_update_ptr %>
66-
<% } -%>
67-
<% unless $ipa_automount_location =~ Undef { -%>
68-
ipa_automount_location = <%= $ipa_automount_location %>
69-
<% } -%>
70-
<% unless $ipa_hbac_refresh =~ Undef { -%>
71-
ipa_hbac_refresh = <%= $ipa_hbac_refresh %>
72-
<% } -%>
73-
<% unless $ipa_hbac_search_base =~ Undef { -%>
74-
ipa_hbac_search_base = <%= $ipa_hbac_search_base %>
75-
<% } -%>
76-
<% unless $ipa_hbac_selinux =~ Undef { -%>
77-
ipa_hbac_selinux = <%= $ipa_hbac_selinux %>
78-
<% } -%>
79-
<% unless $ipa_host_search_base =~ Undef { -%>
80-
ipa_host_search_base = <%= $ipa_host_search_base %>
81-
<% } -%>
82-
<% unless $ipa_master_domains_search_base =~ Undef { -%>
83-
ipa_master_domains_search_base = <%= $ipa_master_domains_search_base %>
84-
<% } -%>
85-
<% unless $ipa_selinux_search_base =~ Undef { -%>
86-
ipa_selinux_search_base = <%= $ipa_selinux_search_base %>
87-
<% } -%>
88-
<% unless $ipa_subdomains_search_base =~ Undef { -%>
89-
ipa_subdomains_search_base = <%= $ipa_subdomains_search_base %>
90-
<% } -%>
91-
<% unless $ipa_views_search_base =~ Undef { -%>
92-
ipa_views_search_base = <%= $ipa_views_search_base %>
93-
<% } -%>
94-
<% unless $krb5_confd_path =~ Undef { -%>
95-
krb5_confd_path = <%= $krb5_confd_path %>
96-
<% } -%>
97-
<% unless $krb5_realm =~ Undef { -%>
98-
krb5_realm = <%= $krb5_realm %>
99-
<% } -%>
100-
krb5_store_password_if_offline = <%= $krb5_store_password_if_offline %>
101-
ldap_tls_cacert = <%= $ldap_tls_cacert %>
102-
ldap_tls_cipher_suite = <%= $ldap_tls_cipher_suite.join(':') %>
7+
<%= $content %>

0 commit comments

Comments
 (0)