Deploying Puppet code

Deployment of Puppet code is, most of the times, a matter of updating modules, manifests, and Hiera data on relevant directories of the Puppet Master.

We deal with two different kinds of code which involve different management patterns:

  • Our modules, manifests, and data
  • The public modules we are using

We can manage them in the following ways:

  • Using Git—eventually using Git submodules for each Puppet module
  • Using the puppet module, for the public modules published on the Forge
  • Using tools such as librarian-puppet and r10k
  • Using other tools or custom procedures we might write specifically for our needs

Using librarian-puppet for deployments

Librarian-puppet (http://librarian-puppet.com) has been developed to manage the installation of a set of modules from the Puppet Forge or any Git repository. It is based on Puppetfile where the modules and the versions to be installed are defined:

forge "http://forge.puppetlabs.com"

# Install a module from the Forge
mod 'puppetlabs/concat'

# Install a specific version of a module from the Forge
mod 'puppetlabs/stdlib', '2.5.1'

# Install a module from a Git repository
mod 'mysql',
  :git => 'git://github.com/example42/puppet-mysql.git',

# Install a specific tag of a module from a Git repository
mod 'mysql',
  :git => 'git://github.com/example42/puppet-mysql.git',
  :ref => 'v2.0.2'

# Install a module from a Git repository at a defined branch 
mod 'mysql',
  :git => 'git://github.com/example42/puppet-mysql.git',
  :ref => 'origin/develop'

In our modulepath, we can install all the modules referenced in the local Puppetfile using:

librarian-puppet install

Deploying code with r10k

r10k has been written by Adrien Thebo, who works in Puppet Labs, to manage deployment of Puppet code from Git repositories or the Forge. It fully supports librarian-puppet's format for the Puppetfile but is an alternative tool that empowers a workflow based on Puppet's dynamic environments.

It can be installed as gem:

gem install r10k

In its configuration file, /etc/r10k.yaml, we define one or more source Git repositories to deploy in the defined basedir:

:cachedir: '/var/cache/r10k'
:sources:
  :site:
    remote: 'https://github.com/example/puppet-site'
    basedir: '/etc/puppetlabs/code/environments'

The interesting thing is that for each branch of our Git source, we find a separated directory inside the defined basedir, which can be dynamically mapped to Puppet environments.

To run a deploy from the repository where we have a Puppetfile we can run:

r10k deploy environments -p 

This creates a directory for each branch of our repository under /etc/puppet/environments, and inside these directories, we find all the modules defined in the Puppetfile under the modules/ directory.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.165.247