You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -204,9 +211,11 @@ Determines whether the specified setting should exist. Valid options: 'present'
204
211
205
212
**NOTE:** The way this type finds all sections in the file is by looking for lines like `${section_prefix}${title}${section_suffix}`
206
213
207
-
### Type: ini_subsetting
208
214
209
215
216
+
217
+
### Type: ini_subsetting
218
+
210
219
Manages multiple values within the same INI setting.
211
220
212
221
#### Parameters
@@ -248,6 +257,134 @@ Specifies whether the subsetting should be present. Valid options: 'present' and
248
257
249
258
*Optional.* Supplies a value for the specified subsetting. Valid options: a string. Default value: undefined.
250
259
260
+
261
+
262
+
263
+
### Function: create_ini_settings
264
+
265
+
`create_ini_settings($settings, $defaults)`
266
+
267
+
Manage multiple ini_setting resources from a hash with comfort. You can provide a hash in your manifest and feed it from Hiera. This can however not be used with ini_subsettings!
268
+
269
+
#### Parameters
270
+
271
+
##### `$settings`
272
+
273
+
*Required.* Specify a hash with the ini_setting resources.
This most certainly is not what you want, but if you need it it's there.
331
+
332
+
Default value: '{}'.
333
+
334
+
#### Example with Hiera
335
+
This example will need Puppet 3.x/4.x as it uses automatic retrieval of Hiera data for class parameters and
336
+
`puppetlabs/stdlib` (you use that one already, don't you?).
337
+
338
+
Of course you may use `hiera_hash` when on Puppet 2.x or other use cases. Remember this is only one example,
339
+
feel free to live your creativity on writing manifests.
340
+
341
+
Imagine a profile `example`:
342
+
~~~
343
+
class profile::example (
344
+
$settings,
345
+
) {
346
+
validate_hash($settings)
347
+
$defaults = { 'path' => '/tmp/foo.ini' }
348
+
create_ini_settings($settings, $defaults)
349
+
}
350
+
~~~
351
+
352
+
Now provide this in your Hiera data:
353
+
~~~
354
+
profile::example::settings:
355
+
section1:
356
+
setting1: value1
357
+
setting2: value2
358
+
setting3:
359
+
ensure: absent
360
+
~~~
361
+
362
+
This will result in resources:
363
+
~~~
364
+
ini_setting { '[section1] setting1':
365
+
ensure => present,
366
+
section => 'section1',
367
+
setting => 'setting1',
368
+
value => 'value1',
369
+
path => '/tmp/foo.ini',
370
+
}
371
+
ini_setting { '[section1] setting2':
372
+
ensure => present,
373
+
section => 'section1',
374
+
setting => 'setting2',
375
+
value => 'value2',
376
+
path => '/tmp/foo.ini',
377
+
}
378
+
ini_setting { '[section1] setting3':
379
+
ensure => absent,
380
+
section => 'section1',
381
+
setting => 'setting3',
382
+
path => '/tmp/foo.ini',
383
+
}
384
+
~~~
385
+
386
+
387
+
251
388
##Limitations
252
389
253
390
This module has been tested on [all PE-supported platforms](https://forge.puppetlabs.com/supported#compat-matrix), and no issues have been identified. Additionally, it is tested (but not supported) on Windows 7, Mac OS X 10.9, and Solaris 12.
0 commit comments