Re: [vagrant-up] How to automate installation of Puppet modules from Puppet Forge?

8,146 views
Skip to first unread message

Simon McCartney

unread,
Oct 23, 2012, 6:43:13 AM10/23/12
to vagra...@googlegroups.com
The pattern I've seen most used for this is maintaining a git repo of your vagrant directorty (the one with Vagrantfile in it), and then cloning puppet modules out as submodules, although puppet librarian might make this even easier?

Here's a vagrant repo I use for working on one of my modules:  https://github.com/simonmcc/vagrant-logstash, this uses "git submodule" to pull in the logstash module from github.

Using librarian to manage modules from both the forge & github seems cleaner, you're "important content" for a Vagant box would be Vagrantfile & Puppetfile.
There's more on puppet-librarian here: https://github.com/rodjek/librarian-puppet

so a "fresh build" would look like

vagrant destroy
librarian-puppet install
vagrant up

Your Vagrantfile can then make full use of all of the modules.

Simon.

On 22 October 2012 19:33, David Edwards <da...@more.fool.me.uk> wrote:
I am trying to provision a Vagrant box using puppet, and to avoid reinventing the wheel I would like to make use of modules downloaded from Puppet Forge such as apache and mysql. In the spirit of keeping the process automated I do not want to duplicate or install the modules locally before provisioning.

Is it possible to configure Vagrant and/or Puppet to install the modules as part of the provisioning process?

The closest I've managed so far is to add an "exec" type to my Puppet manifest that runs the "puppet module install" command:

exec { "puppet module install puppetlabs-mysql":
  path    => "/usr/bin:/usr/sbin:/bin",
  onlyif  => "test `puppet module list | grep puppetlabs-mysql | wc -l` -eq 0"
}

This works on its own, but I can't actually use the modules in the manifest because Puppet won't compile the manifest if the modules are not already installed.

Is there a clever way of doing this that I have missed?

Thanks,

David



--
Simon McCartney

David Edwards

unread,
Oct 23, 2012, 9:36:03 AM10/23/12
to vagra...@googlegroups.com
Thanks, Simon. I had seen submodules used elsewhere, but although it works I felt there were a number of aspects to this approach that were not ideal. I will have a play with librarian-puppet next. I like the way it allows modules to be installed from both forge and git sources.

David

QUinton Anderson

unread,
Oct 26, 2012, 1:10:48 AM10/26/12
to vagra...@googlegroups.com
This is indeed an interesting topic, I didn't actually research it before picking an approach. I simply went with cloning and then putting symbolic links in place to pull the various clones in.

I find it interesting that you would pull all of these onto the host and allow vagrant to do all the provisioning. My approach as always been that vagrant should bring up the base VM, provision just want is required to do provisioning (I know that sounds strange), and then let the remainder of the provisioning take place within the VM itself. So vagrant provisions puppet and git only, and then lets the remainder of provisioning take place in the VM. This way I can let the VM manage itself later without involving vagrant, which is important for things like continuous delivery and basic IT ops. I don't use puppet master, I simply use GIT and let the nodes keep themselves up to date using cron. It just scales better, and I like the simplicity.

Not strictly related to your post, but it made me think of that. I will certainly look into librarian. Thanks.

David Edwards

unread,
Nov 22, 2012, 7:51:48 AM11/22/12
to vagra...@googlegroups.com
To follow up on this:

I liked Librarian-puppet, but I wanted to find a way to do all the provisioning using Vagrant without having to install or run additional software on the host.

So, I came up with a solution that uses Librarian-puppet on the guest before Puppet does its provisioning. I've knocked together a simple example project and put it on Github, in case anyone is interested in having a look:


Regards,

David

Simon McCartney

unread,
Nov 22, 2012, 4:38:54 PM11/22/12
to vagra...@googlegroups.com
Nice. Very nice. Beautifully simple & clean. Thanks for sharing.

Simon McCartney
E: si...@mccartney.ie
M: +44 7710 836 915

frantishrek

unread,
Nov 24, 2012, 1:25:14 PM11/24/12
to Vagrant
Thanks for sharing your solution.
It answers to my problem to add librarian-puppet on my projects.

++


2012/11/22 David Edwards <da...@more.fool.me.uk>

gareth rushgrove

unread,
Mar 18, 2013, 11:22:25 AM3/18/13
to vagra...@googlegroups.com
Ha

I too had this problem, and named my solution the same thing :)

https://github.com/garethr/librarian-puppet-vagrant

The implementation is different however. Mine is a vagrant middleware
which negates the need for the extra provisioner.

Gareth
--
Gareth Rushgrove
Web Geek

morethanseven.net
garethrushgrove.com

Dominic Lüchinger

unread,
Mar 18, 2013, 12:08:34 PM3/18/13
to vagra...@googlegroups.com
Hi vagrant community
Nice solution.

There is an other project called Opskelaton (
https://github.com/narkisr/opskeleton) , that I really like.
Although you need librarian-puppet installed on your local machine. But
with 'rvm', this not a big deal.
The pros of Opskelaton is that you can use hiera, static-modules and run
provisioning within the vagrant box.

David: It would be nice to combine your project with Opskelaton.

What I usually do, is to install the latest Puppet version with this
shell script via shell provisioner: https://gist.github.com/dol/5188327

Regards
Dominic

David Edwards

unread,
Mar 20, 2013, 9:52:12 AM3/20/13
to vagra...@googlegroups.com
On 18 March 2013 11:15, teo danciu <teo.d...@gmail.com> wrote:
How do you configure the initial mysql example  using librarian-puppet-vagrant? 
I have added this: "mod "puppetlabs/mysql"  in Puppetfile, but I'm not sure what main.pp should contain.

What you add to main.pp depends on how you want MySQL configured on your Vagrant box. Take a look at the examples under the Usage section on https://github.com/puppetlabs/puppetlabs-mysql

Hope that helps!

David 

David Edwards

unread,
Mar 20, 2013, 10:09:01 AM3/20/13
to vagra...@googlegroups.com
On 18 March 2013 15:22, gareth rushgrove <gareth.r...@gmail.com> wrote:
The implementation is different however. Mine is a vagrant middleware
which negates the need for the extra provisioner.

Hi Gareth,

Interesting... The rationale behind my solution was to automate as much as possible and avoid having to install additional software on the host. Hence my provisioner installs librarian-puppet on the guest and runs it from there too.

David

David Edwards

unread,
Mar 20, 2013, 10:14:14 AM3/20/13
to vagra...@googlegroups.com
On 18 March 2013 16:08, Dominic Lüchinger <d.luec...@snowgarden.ch> wrote:
There is an other project called Opskelaton ( https://github.com/narkisr/opskeleton) , that I really like.

Looks interesting, thanks.
 
David: It would be nice to combine your project with Opskelaton.

I only really created my project as light-weight example of the approach I was taking. But if anyone wants to reuse/re-purpose what I've done please feel free.

David 
Reply all
Reply to author
Forward
0 new messages