Featured Post

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.

  • On the master node:

    • Append following details in puppet.conf which is placed under /etc/puppet or /etc/puppetlabs/puppet:
    Under [main] section add a variable called confdir with value as /etc/puppet or /etc/puppetlabs/puppet
    confdir=/etc/puppet
    • Then add information regarding environments/manifests and modulepath in it.
    #environments
    environmentpath = $confdir/environments
    default_manfiest = $confdir/manifests

    basemodulepath = $confdir/modules:/opt/puppet/share/puppet/modules
    • Then create a folder for environments under $confdir
    [root@sunnybbee environments]# pwd
    /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:
    Under [agent] section add below information, make sure to follow the same on other agent nodes as well.
    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?

Go to your master node and fire something like this:

=> 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

Popular posts from this blog

Exec in Puppet

Un-revoke the revoked certificate in Puppet

Dry run in Puppet --noop