1
votes

I am having trouble setting my modulepath on my puppet master.

# puppet -V
4.10.5

Here is the default modulepath

# puppet config print modulepath
/etc/puppetlabs/code/environments/production/modules:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules

I have to add two directories ...

  • /etc/puppetlabs/code/environments/production/modules/tools
  • /etc/puppetlabs/code/environments/production/modules/core

... to my modulepath. So I am doing this:

# puppet config set modulepath "/etc/puppetlabs/code/environments/production/modules/tools:/etc/puppetlabs/code/environments/production/modules/core:`puppet config print modulepath`"

But I get this error:

# puppet config print modulepath
Error: Could not initialize global default settings: Cannot set modulepath settings in puppet.conf

The modulepath in my puppet.conf looks ok:

# grep modulepath /etc/puppetlabs/puppet/puppet.conf
modulepath = /etc/puppetlabs/code/environments/production/modules/tools:/etc/puppetlabs/code/environments/production/modules/core:/etc/puppetlabs/code/environments/production/modules:/etc/puppetlabs/code/modules:/opt/puppetlabs/puppet/modules

I am doing something wrong or is this a bug?

2
Since those two additional modulepaths are specific to your production directory environment, try appending them to your basemodulepath (from the puppet.conf) in your environment.conf for production: docs.puppet.com/puppet/4.10/config_file_environment.html. - Matt Schuchard
Thanks. Setting the modulepath in the environment.conf seems to work. It strange that puppet config set modulepath ... doesn't update the environment.conf. - Red Cricket
Want me to write it up as an answer? - Matt Schuchard
That's up to you. I'd up vote and accept it. - Red Cricket

2 Answers

4
votes

These extra module paths are specific to your production directory environment, so they can be appended in your production directory environment's environment.conf like such:

# /etc/puppetlabs/code/environments/production/environment.conf  
/etc/puppetlabs/code/environments/production/modules/tools:/etc/puppetlabs/code/environments/production/modules/core:$basemodulepath

Your $basemodulepath is specified in your puppet.conf, typically at /etc/puppetlabs/puppet/puppet.conf. It is the value for basemodulepath in the INI format. modulepath from the config file is not used in the directory environment according to the documentation.

More information about environment.conf: https://docs.puppet.com/puppet/4.10/config_file_environment.html More information about appending module paths in your directory environment: https://docs.puppet.com/puppet/4.10/config_file_environment.html#modulepath

0
votes

lets say you want to list the modules you have installed in your modulepath and would like to write:

puppet module list

instead of :

puppet module list --modulepath=C:\tmp\modules

then you could set the modulepath by setting the basemodulepath like this:

puppet config set basemodulepath "C:\tmp\modules"

This creates a file puppet.conf inside puppetlabs ; under windows it could be here:

C:\Users\< username >\.puppetlabs\etc\puppet

you would then afterwards beable to list your installed modules like this:

puppet module list

if you use modulepath and not basemodulepath then puppet will try to set modulepath everytime causing your error