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 (https://github.com/puppetlabs/puppetl...):

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

  # for some reason, 
  $autofs_config = {
    '' => {
      'SEARCH_BASE' => '"ou=it.example.com,o=nl,dc=example,dc=com"',
      'SEARCH_BASE' => '"ou=it.examplecorp.com,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:

SEARCH_BASE="ou=it.examplecorp.com,o=nl,dc=example,dc=com"
SEARCH_BASE="ou=it.examplecorp.com,o=nl,dc=example,dc=com"

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

edit retag flag offensive close merge delete

Comments

1

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: https://linux.die.net/man/5/auto.master 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