I'm setting up a Puppet master server for the first time. It's configured to use environments:
/etc/puppet/puppet.conf:
[main]
environmentpath = /var/opt/puppet/environments
basemodulepath = /var/opt/puppet/modules
Whenever I install a module, puppet module install foo
, it get installed into my "production" environment's module directory. What I want to happen is for the module to be installed to /var/opt/puppet/modules
unless I specify an environment with the --environment
switch.
How do I do that?
As of the current Puppet version (v6.0):
That means you need to set the modulepath so that '/var/opt/puppet/modules' is the first directory in your modulepath. Since the modulepath setting can only be set in environment.conf, you need to edit your environment.conf for all of your environments.
nano -w /etc/puppetlabs/code/environments/{environment_name}/environment.conf
BTW: For Puppet v6.0 '/etc/puppetlabs/code/modules' may be a better choice for a global modules directory.
You are using environment config sections. So, you can set modulepath in each environment’s section of puppet.conf. Like...
[main]
--
environmentpath = /var/opt/puppet/environments
basemodulepath = /var/opt/puppet/modules
--
[production]
--
--
[dev]
--
--
If that setting is absent in a given environment, Puppet will fall back to the global value of the modulepath setting(/var/opt/puppet/modules). Or you can specify the separate module path for each directory sections. Hope you got the answer...
Each environment can have its own 'modulepath' if you create an
environment.conf
file within the environment directory.More information on environments can be found on the Puppet labs website here:
https://puppet.com/docs/puppet/latest/env_environments.html