In the last blog which features installing and configuring Puppet with LDAP as configuration store here .
Note : Environments were introduced in Puppet 0.24.0.
What an Environment is :
Puppet lets you slice your site up into an arbitrary number of “environments” and serve a different set of modules to each one. This is usually used to manage releases of Puppet modules by testing them against scratch nodes before rolling them out completely, but it introduces a lot of other possibilities, like separating a DMZ environment, splitting coding duties among multiple sysadmins, or dividing the site by hardware type.
Every client node has an environment, and the puppet master gets informed about it whenever that node makes a request. (If you don’t specify an environment, the puppet client has the default “production” environment.)
The puppet master can then use that environment several ways:
In short: modules and manifests can already do different things for different nodes, but environments let the master tweak its own configuration on the fly, and offer a way to completely swap out the set of available modules for certain nodes.
Configuring Environments on Puppet Master :
To define an environment master-side, just add
Note : File serving only works well with environments if you’re only serving files from modules; if you’ve set up custom mount points in
For serving files for specific environment , just add
Configuring Environments on Puppet Master for specific Host through LDAP node :
Create LDAP node for holding parameter for all machines .parent.ldif contains all configuration (puppetVar) that are inherited by all host. We can see both host specific ldif contains environment variable specifing its environment.
/usr/local/etc/openldap/parent.ldif
Add parent directory entry :
Create LDAP directory for myhost1 containing host specific environment variable.
/usr/local/etc/openldap/myhost1.ldif
Add Ldap directory entry for host myhost1:
Create LDAP directory for myhost2 containing host specific environment variable.
/usr/local/etc/openldap/myhost2.ldif
Add directory entry for host myhost2:
Configuring Environments on Puppet Client :
To set an environment agent-side, just specify the
As with any config setting, you can also use a command line option:
With an assumption that Puppet master and client were successfully installed and SSL certificate has been signed, I have shown how to configure Puppet Master for serving different puppet recipes ( modules and manifest ) to different environment (development , testing and production etc)
Note : Environments were introduced in Puppet 0.24.0.
What an Environment is :
Puppet lets you slice your site up into an arbitrary number of “environments” and serve a different set of modules to each one. This is usually used to manage releases of Puppet modules by testing them against scratch nodes before rolling them out completely, but it introduces a lot of other possibilities, like separating a DMZ environment, splitting coding duties among multiple sysadmins, or dividing the site by hardware type.
Note : In our development , we are using environment variable to support multiple releases to puppet client.
Every client node has an environment, and the puppet master gets informed about it whenever that node makes a request. (If you don’t specify an environment, the puppet client has the default “production” environment.)
The puppet master can then use that environment several ways:
- If the master’s puppet.conf file has a [config block] for this agent’s environment, those settings will override the master’s normal settings when serving that agent.
- If the values of any settings in puppet.conf reference the $environment variable (like modulepath = $confdir/environments/$environment/modules:$confdir/modules, for example), the agent’s environment will be interpolated into them.
- Depending on how auth.conf is configured, different requests might be allowed or denied. The agent’s environment will also be accessible in Puppet manifests as the top-scope $environment variable.
In short: modules and manifests can already do different things for different nodes, but environments let the master tweak its own configuration on the fly, and offer a way to completely swap out the set of available modules for certain nodes.
Configuring Environments on Puppet Master :
[environment]
block of/etc/puppet/puppet.conf
#Environments
[development]
modulepath =/etc/puppet/development/modules
manifest = /etc/puppet/development/manifest/site.pp
manifestdir = /etc/puppet/development/manifest
templatedir = /etc/puppet/development/templates
[testing]
modulepath =/etc/puppet/testing/modules
manifest = /etc/puppet/testing/manifest/site.pp
manifestdir = /etc/puppet/testing/manifest
templatedir = /etc/puppet/testing/templates
[production]
modulepath =/etc/puppet/production/modules
manifest = /etc/puppet/production/manifest/site.pp
manifestdir = /etc/puppet/production/manifest
templatedir = /etc/puppet/production/templates
Note : File serving only works well with environments if you’re only serving files from modules; if you’ve set up custom mount points in
fileserver.conf
, they won’t work in your custom environments.For serving files for specific environment , just add
[environment]
block of
/etc/puppet/fileserver.conf
#Environments
[development]
path /etc/puppet/development/files
allow *
[testing]
path /etc/puppet/testing/files
allow *
[production]
path /etc/puppet/production/files
allow *
Set Environment through Manifest
T
he $environment variable can be used to set environment of specific host in manifest.If no $environment variable set, then by default [production] environment sevred.
Configuring Environments on Puppet Master for specific Host through LDAP node :Create LDAP node for holding parameter for all machines .parent.ldif contains all configuration (puppetVar) that are inherited by all host. We can see both host specific ldif contains environment variable specifing its environment.
/usr/local/etc/openldap/parent.ldif
dn: cn=parentnode,dc=mypuppet,dc=com
objectClass: device
objectClass: puppetClient
objectClass: top
puppetVar: tomcatport=8080
cn: parentnode
Add parent directory entry :
$ /usr/bin/ldapadd -h 192.168.145.117 -p 389 -x -D "cn=Manager, dc=mypuppet, dc=com" -w yourldappassword -f /usr/local/etc/openldap/parent.ldif
Create LDAP directory for myhost1 containing host specific environment variable.
/usr/local/etc/openldap/myhost1.ldif
dn: cn=myhost1,dc=mypuppet,dc=com
environment: production
objectClass: device
objectClass: puppetClient
objectClass: top
parentNode: parentnode
puppetClass: tomcat
puppetVar: tomcatport=9000
cn: myhost1
Add Ldap directory entry for host myhost1:
$ /usr/bin/ldapadd -h 192.168.145.117 -p 389 -x -D "cn=Manager,dc=mypuppet,dc=com" -w yourldappassword -f /usr/local/etc/openldap/myhost1.ldif
Create LDAP directory for myhost2 containing host specific environment variable.
/usr/local/etc/openldap/myhost2.ldif
dn: cn=myhost2,dc=mypuppet,dc=com
environment: development
objectClass: device
objectClass: puppetClient
objectClass: top
parentNode: parentnode
puppetClass: tomcat
puppetVar: tomcatport=8000
cn: myhost2
Add directory entry for host myhost2:
$ /usr/bin/ldapadd -h 192.168.145.117 -p 389 -x -D "cn=Manager,dc=mypuppet,dc=com" -w yourldappassword -f /usr/local/etc/openldap/myhost2.ldif
Configuring Environments on Puppet Client :
To set an environment agent-side, just specify the
environment
setting in either the[puppetd]
or [main]
block of /etc/puppet/puppet.conf
[puppetd]
environment = development
As with any config setting, you can also use a command line option:
$ sudo /usr/sbin/puppetd --environment development
References :
http://docs.puppetlabs.com/guides/environment.html
No comments:
Post a Comment