|
74 | 74 | # |
75 | 75 | # @param ensure Whether to ensure presence or absence of the resource |
76 | 76 | # |
77 | | -# @param inifile_defaults Default parameters to parse to inifile provider |
78 | | -# |
79 | 77 | define dconf::db ( |
80 | 78 | Optional[Hash] $settings = undef, |
81 | 79 | Optional[Array] $locks = undef, |
|
91 | 89 | String $locks_file_mode = '0644', |
92 | 90 | Boolean $purge = true, |
93 | 91 | Enum['present','absent'] $ensure = 'present', |
94 | | - Hash $inifile_defaults = { ensure => 'present', path => $db_file, notify => Exec['dconf_update'], require => File[$db_file], }, |
95 | 92 | ) { |
96 | 93 | case $ensure { |
97 | 94 | 'present': { |
|
102 | 99 | recurse => $purge, |
103 | 100 | force => $purge, |
104 | 101 | }) |
| 102 | + $_db_file_header = epp('dconf/header.epp') |
| 103 | + $_db_file_body = epp('dconf/db.epp', { |
| 104 | + 'settings' => $settings |
| 105 | + } |
| 106 | + ) |
105 | 107 | file { $db_file: |
106 | 108 | ensure => 'file', |
107 | 109 | mode => $db_file_mode, |
| 110 | + content => "${_db_file_header}${_db_file_body}", |
108 | 111 | require => File[$db_dir], |
109 | | - } |
110 | | - if $settings { |
111 | | - $settings.each |String $section, Hash $key_vals| { |
112 | | - $key_vals.each |String $setting, $value| { |
113 | | - ini_setting { "db_${name}_settings_${section}_${setting}": |
114 | | - path => $db_file, |
115 | | - section => $section, |
116 | | - setting => $setting, |
117 | | - value => $value, |
118 | | - notify => Exec['dconf_update'], |
119 | | - } |
120 | | - } |
121 | | - } |
| 112 | + notify => Exec['dconf_update'], |
122 | 113 | } |
123 | 114 | if $locks { |
124 | 115 | ensure_resource(file, $locks_dir, { |
|
127 | 118 | purge => $purge, |
128 | 119 | recurse => $purge, |
129 | 120 | }) |
130 | | - concat { "db_${name}_locks": |
| 121 | + $_locks_file_header = epp('dconf/header.epp') |
| 122 | + $_locks_file_body = epp('dconf/locks.epp', { |
| 123 | + 'locks' => $locks |
| 124 | + } |
| 125 | + ) |
| 126 | + file { "db_${name}_locks": |
| 127 | + ensure => $ensure, |
131 | 128 | path => $locks_file, |
132 | 129 | mode => $locks_file_mode, |
133 | | - order => 'alpha', |
| 130 | + content => "${_locks_file_header}${_locks_file_body}", |
134 | 131 | require => File[$locks_dir], |
135 | | - } |
136 | | - $locks.each |$lock| { |
137 | | - concat::fragment { "db_${name}_locks_${lock}": |
138 | | - target => $locks_file, |
139 | | - content => "${lock}\n", |
140 | | - require => Concat["db_${name}_locks"], |
141 | | - notify => Exec['dconf_update'], |
142 | | - } |
| 132 | + notify => Exec['dconf_update'], |
143 | 133 | } |
144 | 134 | } |
145 | 135 | } |
|
0 commit comments