Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I install puppet modules through puppet manifest?

Tags:

puppet

Primary goal is to add all puppet modules automatically, so that all dev-env's and prod-env could be started with one command. How can I install puppet modules through puppet manifest?

like image 427
holms Avatar asked May 27 '13 14:05

holms


People also ask

What is Puppet Module and how is it different from Puppet manifest?

A module is a collection of manifests and data (such as facts, files, and templates), and they have a specific directory structure. Modules are useful for organizing your Puppet code, because they allow you to split your code into multiple manifests.

Where do I put Puppet modules?

The puppet module install command installs a module and all of its dependencies. You can install modules from the Forge, a module repository, or a release tarball. By default, this command installs modules into the first directory in the Puppet modulepath, which defaults to $codedir/environments/production/modules .

What does Puppet mean by manifests?

A manifest is a file containing Puppet configuration language that describes how resources should be configured. The manifest is the closest thing to what one might consider a Puppet program. It declares resources that define state to be enforced on a node.


2 Answers

We've been happily using librarian-puppet to sync all 3rd party modules, it supports setting the modules' locations and versions. So production and dev run the exact same code. The usage is one liner

librarian-puppet install

In other cases we have a shell script that runs puppet two times, one time a minimal module that is only responsible for fetching the required modules, and then the full blown puppet flow when all modules are available.

like image 104
LiorH Avatar answered Oct 11 '22 18:10

LiorH


The "Puppet module" type and provider does exactly that:

module { 'author/mymodule':
  ensure   => present,
}
module { 'puppetlabs/stdlib':
  ensure => '2.6.0',
}
module { 'puppetlabs/stdlib':
  ensure     => present,
  modulepath => '/etc/puppet/modules',
}

Recent versions of Puppet also have a puppet module command that allows you to install arbitrary Puppet modules from the Puppet forge, example:

$ puppet module install rcoleman/puppet_module
Notice: Preparing to install into /home/anarcat/.puppet/modules ...
Notice: Created target directory /home/anarcat/.puppet/modules
Notice: Downloading from https://forgeapi.puppetlabs.com ...
Notice: Installing -- do not interrupt ...
/home/anarcat/.puppet/modules
└── rcoleman-puppet_module (v0.0.3)

Other alternatives include:

  • librarian
  • r10k (cited as a replacement for librarian), supports dynamic environments and much more

r10k is now part of Puppet Entreprise 2015.03, so it can certainly be considered best practice.

like image 39
anarcat Avatar answered Oct 11 '22 17:10

anarcat