Skip to content

Latest commit

 

History

History
95 lines (64 loc) · 2.86 KB

File metadata and controls

95 lines (64 loc) · 2.86 KB

Puppet related recommendations

About modules and manifests

Puppet Modules and Manifests

Puppetfile: describe modules

The puppetfile is the file where describe which puppet modules are going to be available in the context.

The context is common for all the images in a service.

This is the official puppetfile documentation.

It is recommended to specify package version for the modules.

Remember to add also the dependences of each module.

This is an example:

forge "https://forgeapi.puppetlabs.com"

mod 'puppetlabs-apt',
  :git => "git://github.com/puppetlabs/puppetlabs-apt.git",
  :ref => "2.1.1"

mod 'puppetlabs-stdlib',
  :git => "https://github.com/puppetlabs/puppetlabs-stdlib",
  :ref => "4.9.0"

mod 'puppetlabs-concat',
  :git => "https://github.com/puppetlabs/puppetlabs-concat",
  :ref => "1.2.4"

mod 'puppet-python',
  :git => "https://github.com/stankevich/puppet-python",
  :ref => "1.9.8"

mod 'puppetlabs-vcsrepo',
  :git => "https://github.com/puppetlabs/puppetlabs-vcsrepo",
  :ref => "1.3.1"

Puppet manifests

This is the file that describes the actions to apply in a system (a container in our case).

Here it is the offcial language documentation.

Maybe it's more practical to start from examples and look at the specific module documentation.

This is an example for installing a python application from a github repo:

# Clone repo
vcsrepo { '/usr/src/app':
  ensure   => present,
  provider => git,
  source   => 'git://github.com/wtelecom/crane-tests-webconsumer.git',
}

# Install requirements
class { 'python' :
  version    => 'system',
  pip        => 'present',
  dev        => 'present',
}

exec { "requirements":
    command => "pip install -r requirements.txt",
    cwd     => "/usr/src/app",
    path    => "/usr/local/bin/:/bin/:/usr/bin",
    require => Class["python"]
}

Advices

Do not launch services in the manifest

Avoid to use directives that start the services (like ensure => 'running').

Manifests are applied in building time, not execution time.

The 'start command' has to be written in the Dockerfile (CMD) or in the docker-compose file with command.

Assure that the manifest has everything to work

The base images we are using are really skinny, you need to install everything you want to use.

For example:

  • If you want to install a package from apt-get, you need first to make an apt-get update because the cache is empty.
  • If you want to clone a repo, you need to install the git tool.
  • If you want to un-zip something, check that unzip is installed.