Sunday, February 15, 2015

Daily Puppet - Puppet Environment Directories

Puppet environments can help to differentiate between the level of code, like production, staging, development. 

To setup the Directory environments, we need to make some changes to the default puppet.conf file.




Once these changes are applied, we will need to restart the puppet master service. 

We have set the environment folders to be searched in the path “/etc/puppet/environments”, by using the configuration directive,
environmentpath = $confdir/environments


We will now create a staging environment for a test module “mytestmodule”




Our init.pp file is a simple one, which will create a test file.We will assign the module to the node.



Now, we test our environment,

puppet agent --noop --test --server centos  --environment=staging
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for centos
Info: Applying configuration version '1424034120'
Notice: /Stage[main]/Mytestmodule/File[/home/testingenv.txt]/ensure: current_value absent, should be present (noop)
Notice: Class[Mytestmodule]: Would have triggered 'refresh' from 1 events
Notice: Stage[main]: Would have triggered 'refresh' from 1 events
Notice: Finished catalog run in 0.03 seconds

This kind of set up is very helpful, when we want to separate our production code from the testing code. 










No comments:

Post a Comment