How can I add multiple entries to an ini file with the same key using inifile module?

asked 2017-03-09 16:30:55 -0500

wfsaxton gravatar image

updated 2017-03-09 16:31:07 -0500

I'm following the directions for adding multiple entries to an ini file using the inifile module (

$autofs_config_defaults = {
    'path' => '/etc/sysconfig/autofs'  

  # for some reason, 
  $autofs_config = {
    '' => {
      'SEARCH_BASE' => '",o=nl,dc=example,dc=com"',
      'SEARCH_BASE' => '",o=nl,dc=example,dc=com"',

  create_ini_settings($autofs_config, $autofs_config_defaults)

Because it uses a hash, I end up with this in my INI file:


Is there a way to handle this scenario with the inifile module?

edit retag flag offensive close merge delete



Specifying the same key multiple times in a section doesn't quite go along with the *.ini-file specification, does it? Because that could be why there's no way to handle your situation with that module.

Kai Burghardt gravatar imageKai Burghardt ( 2017-03-09 18:14:20 -0500 )edit

It's definitely supported: Quote: "This entry may be given multiple times"

wfsaxton gravatar imagewfsaxton ( 2017-03-09 22:53:34 -0500 )edit

Yeah, I mean the inifile module you're using, it is aimed at standard *.ini files, which usually don't have the same key multiple times. However auto.master(5) differs from that standard allowing SEARCH_BASE to appear multiple times. Isn't there a more appropriate autofs puppet module?

Kai Burghardt gravatar imageKai Burghardt ( 2017-03-11 10:33:40 -0500 )edit

I'm using "puppet/autofs" so I assume that's the most desirable module to use :) I see 3.0.2 is now available (2.0.1 was available last time I responded here) so I'll see if that does anything.

wfsaxton gravatar imagewfsaxton ( 2017-05-30 14:48:58 -0500 )edit