Migrate from config file environments to directory environments

220 views
Skip to first unread message

jmp242

unread,
Oct 1, 2014, 12:35:43 PM10/1/14
to puppet...@googlegroups.com

Ok, I use TheForeman, and recently updated from puppet 3.4.3 to 3.7.1. I also updated TheForeman to 1.6.0. I have had config file environments. One wrinkle was I had modules as $confdir/environments/dev - and all the modules are under here, no sub modules dir. I tried to migrate to directory environments by moving my modules to $confdir/environments/dev/modules for instance, and removing the config definitions in puppet.conf and adding environmentpath=$confdir/environments to puppet.conf.I restarted apache, but my clients could no longer find their modules. I've poured over the docs, but can't see what I did wrong. Is there a doc with step by step example of converting the type of environments to be puppet4 compatible?


Because of TheForeman, I don't have anything in site.pp... But maybe I need blank site.pp in each environment? Can Puppet work without a default manifest? The docs imply it should process a blank one if one doesn't exist... Do I have to have an environment.conf that specifies an empty site.pp? It is really not clear from the docs.

jmp242

unread,
Oct 1, 2014, 8:15:45 PM10/1/14
to puppet...@googlegroups.com

Ok, so some more reading, and ignoring what seemed to be wrong one liners in the documentation, I found out I needed to have the setup like this:

environment/modules

environment/manifests

environment/manifests/site.pp <- which I did need some settings in, namely  Package {  allow_virtual => false, } (or true) and a path definition so all my short paths could work. I may in fact want to edit this to split path for windows and linux, but for now it seems to work with that structure. 3.7.1 does not, in fact, seem to work with a non-existant site.pp inside the directory environments...

Barry Gestwicki

unread,
Oct 1, 2014, 8:48:22 PM10/1/14
to puppet...@googlegroups.com
Hi jmp252!

I recently made the very same transition and banged my head against a wall for a while, but finally got it working, and perhaps this isn't the only solution or appropriate approach, but it's what's worked for me.  At a bare minimum, you should have "environmentpath = $confdir/environments" in puppet.conf (which it sounds like you already have), and the directory structure $confdir/environments/production/{manifests,modules}, as "production" is the default environment used for all hosts in Puppet/Foreman.  Of course, you can add environments in Foreman, and then you would just need a $confdir/environments/<environment_name>/{manifests,modules} directory structure for each additional one. 

Furthermore, I have an environment.conf file in each environment's directory (i.e /etc/puppet/environments/production/) that specifies a path for the manifests and modules, akin to the following, going along with the production example :

manifest = $confdir/environments/production/manifests
modulepath = $confdir/environments/production/modules

Of course, you will need a site.pp in each environment's "manifests" directory and at least one class in the "modules" directory that's being declared for a Puppet run to actually do anything.  Hopefully this helps, but feel free to let me know if you need any additional info or assistance!

## Example Structure ##
/etc/puppet/environments/production
/etc/puppet/environments/production/environment.conf
/etc/puppet/environments/production/manifests
/etc/puppet/environments/production/manifests/site.pp
/etc/puppet/environments/production/modules
/etc/puppet/environments/production/modules/ntp
/etc/puppet/environments/production/modules/ntp/{blah, blah, blah}

BG
Reply all
Reply to author
Forward
0 new messages