Environments

Puppet Environments offer a way to have completely separated environments on a Puppet Server, each of which has its own classes, modules, manifests, nodes, anything. When a client contacts the server, it must be determined in which environment it belongs.

  1. root@vhost1:~# mkdir -p /srv/puppet/envs/{production,testing}/{modules,templates,manifests}
    root@vhost1:~# touch /srv/puppet/envs/{production,testing}/manifests/site.pp

    Add to the end of /etc/puppet/puppet.conf:

    [production]
        modulepath  = /srv/puppet/envs/production/modules
        templatedir = /srv/puppet/envs/production/templates
        manifestdir = /srv/puppet/envs/production/manifests
        manifest    = /srv/puppet/envs/production/manifests/site.pp
    
    [testing]
        modulepath  = /srv/puppet/envs/testing/modules
        templatedir = /srv/puppet/envs/testing/templates
        manifestdir = /srv/puppet/envs/testing/manifests
        manifest    = /srv/puppet/envs/testing/manifests/site.pp
    	  

    And restart Apache (since we're using mod_passenger):

    root@vhost1:~# apachectl restart

  2. -bash-4.1# cat <<EOF >> /etc/puppet/puppet.conf 
    [agent]
    environment=testing
    EOF

    -bash-4.1# puppet agent --configprint environment
    testing
    -bash-4.1# puppet agent -t
    Info: Caching certificate for vhost4.xennet
    Info: Caching certificate_revocation_list for ca
    Info: Retrieving plugin
    Info: Caching catalog for vhost4.xennet
    Info: Applying configuration version '1384119237'
    Info: Creating state file /var/lib/puppet/state/state.yaml
    Notice: Finished catalog run in 0.07 seconds