Directory environments in Puppet
Environments are individual groups of Puppet agents each environment have there own completely different manifests and module-paths.
This basically is useful for testing changes to our Puppet code before implementing them on production machines.
There are two types of implementation of environments structure in Puppet one if directory based and another is config file based here we will see bit of an insight about directory based.
As usual for more information about this you can visit puppetlabs official website.
confdir=/etc/puppet
This basically is useful for testing changes to our Puppet code before implementing them on production machines.
There are two types of implementation of environments structure in Puppet one if directory based and another is config file based here we will see bit of an insight about directory based.
As usual for more information about this you can visit puppetlabs official website.
On the master node:
- Append following details in puppet.conf which is placed under /etc/puppet or /etc/puppetlabs/puppet:
confdir=/etc/puppet
- Then add information regarding environments/manifests and modulepath in it.
environmentpath = $confdir/environments
default_manfiest = $confdir/manifests
basemodulepath = $confdir/modules:/opt/puppet/share/puppet/modules
- Then create a folder for environments under $confdir
/etc/puppet/environments
[root@sunnybbee environments]#
- Then create directory structure as follows.
|-- acceptance
| |-- manifests
| `-- modules
`-- test
|-- manifests
`-- modules
What does this mean is we are trying to add two environments in a single puppet master and each of one is having there own manifests and module directories.
PS: Each environment has its own site.pp where you need to add your node definition and all.
- After doing these changes make sure to restart your puppet-master so that the application is aware about the change.
On the agent node:
- Append following details in puppet.conf which is placed under /etc/puppet or /etc/puppetlabs/puppet:
server = puppet
# Here puppet is puppet-master, Add details of host-name which is applicable for you.
environment = acceptance
# Here acceptance is the name of the environment.
That's it you are done with configuration of environments on puppet master/agent :)
How to install modules in directory environment?
=> puppet module install --modulepath /etc/puppet/environments/ENVIRONMENT/modules/ MODULENAME
For instance: I need to install an ftp server in my test environment, so what I will do is?
ENVIRONMENT = test
MODULENAME = thias-vsftpd
[root@sunnybbee modules]# puppet module install --modulepath /etc/puppet/environments/test/modules/ thias-vsftpd
Notice: Preparing to install into /etc/puppet/environments/test/modules ...
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/etc/puppet/environments/test/modules
└── thias-vsftpd (v0.2.1)
[root@sunnybbee modules]#
Below is the directory structure for the installed module:
[root@sunnybbee test]# pwd
/etc/puppet/environments/test
[root@sunnybbee test]# tree
.
|-- manifests
| `-- site.pp
`-- modules
`-- vsftpd
|-- ChangeLog
|-- LICENSE
|-- manifests
| |-- init.pp
| `-- params.pp
|-- metadata.json
|-- Modulefile
|-- README.md
|-- templates
| |-- empty.conf.erb
| |-- vsftpd.conf.erb
| `-- vsftpd.conf.orig
`-- tests
`-- init.pp
6 directories, 12 files
[root@sunnybbee test]#
Comments
Post a Comment