Librarian is a bundler for Ruby. It handles dependency checking for you. The project for using Librarian with Puppet is called librarian-puppet
and is available at http://rubygems.org/gems/librarian-puppet. To install librarian-puppet
, we'll use RubyGems since no rpm packages exist in public repositories at this time. To make our instructions platform agnostic, we'll use Puppet to install the package as shown here:
[root@stand ~]# puppet resource package librarian-puppet ensure=installed provider=gem Notice: /Package[librarian-puppet]/ensure: created package { 'librarian-puppet': ensure => ['2.2.1'], }
We can now run librarian-puppet
as follows:
[root@stand ~]# librarian-puppet version librarian-puppet v2.2.1
The librarian-puppet
project uses a Puppetfile
to define the modules that will be installed. The syntax is the name of the module followed by a comma and the version to install. Modules may be pulled in from Git repositories or directly from Puppet Forge. You can override the location of Puppet Forge using a forge
line as well. Our initial Puppetfile
would be the following:
forge "http://forge.puppetlabs.com" mod 'puppetlabs/puppetdb', '5.0.0' mod 'puppetlabs/stdlib', '4.9.0'
We'll create a new public directory in /tmp/public4
and include the Puppetfile
in that directory, as shown here:
[git@stand ~]$ cd /tmp [git@stand tmp]$ mkdir public4 && cd public4 [git@stand public4]$ cat<<EOF>Puppetfile > forge "https://forgeapi.puppetlabs.com" >mod 'puppetlabs/puppetdb', '5.0.0' >mod 'puppetlabs/stdlib', '4.9.0' > EOF
Next, we'll tell librarian-puppet
to install everything we've listed in the Puppetfile
as follows:
[git@stand public4]$ librarian-puppet update [git@stand public4]$ ls modules Puppetfile Puppetfile.lock
The Puppetfile.lock
file is a file used by librarian-puppet
to keep track of installed versions and dependencies; in our example, it contains the following:
FORGE remote: https://forgeapi.puppetlabs.com specs: puppetlabs-apt (2.2.0) puppetlabs-stdlib (< 5.0.0, >= 4.5.0) puppetlabs-concat (1.2.4) puppetlabs-stdlib (< 5.0.0, >= 3.2.0) puppetlabs-firewall (1.7.1) puppetlabs-inifile (1.4.2) puppetlabs-postgresql (4.6.0) puppetlabs-apt (< 3.0.0, >= 1.8.0) puppetlabs-concat (< 2.0.0, >= 1.1.0) puppetlabs-stdlib (~> 4.0) puppetlabs-puppetdb (5.0.0) puppetlabs-firewall (< 2.0.0, >= 1.1.3) puppetlabs-inifile (< 2.0.0, >= 1.1.3) puppetlabs-postgresql (< 5.0.0, >= 4.0.0) puppetlabs-stdlib (< 5.0.0, >= 4.2.2) puppetlabs-stdlib (4.9.0) DEPENDENCIES puppetlabs-puppetdb (= 5.0.0) puppetlabs-stdlib (= 4.9.0)
Our modules are installed in /tmp/public4/modules
. Now, we can go back and add all these modules to our initial Puppetfile
to lockdown the versions of the modules for all our developers. The process for a developer to clone our working tree would be to install librarian-puppet
and then pull down our Puppetfile
. We will add the Puppetfile
to our Git repository to complete the workflow. Thus, each developer will be guaranteed to have the same public module structure.
We can then move these modules to /etc/puppetlabs/code/modules
and change permissions for the Puppet user using the following commands:
[root@stand ~]# cd /tmp/public4/modules/ [root@stand modules]# cp -a . /etc/puppetlabs/code/modules/ [root@stand modules]# chown -R puppet:puppet /etc/puppetlabs/code/modules [root@stand modules]# ls /etc/puppetlabs/code/modules/ apt concat firewall inifile postgresql puppetdb stdlib
This method works fairly well, but we still need to update the modules independently of our Git updates; we need to do these two actions together. This is where r10k comes into play.