Plug Dev Flow with Gush and Bldr into Vagrant

I recently added Gush and Bldr to a vagrant box generated by puphpet.com. I also plugged librarian instead of the regular git tracking of the whole module set. This is a more pro way than to keep track of 2k+ files that are purely git repositories and that are already versioned.

So here are the sparse instructions. For Gush, this is inside vagrant/puphpet/puppet/nodes/gush.pp, yes you just add a gush.pp puppet file into your nodes:

  $gush_github   = 'https://github.com/gushphp/gush.git'
  $gush_location = '/usr/share/gush'
 
  exec { 'delete-gush-path-if-not-git-repo':
    command => "rm -rf ${gush_location}",
    onlyif  => "test ! -d ${gush_location}/.git",
    path    => [ '/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/' ],
  } ->
  vcsrepo { $gush_location:
    ensure   => present,
    provider => git,
    source   => $gush_github,
    revision => 'master',
  } ->
  composer::exec { 'gush':
    cmd     => 'install',
    cwd     => $gush_location,
    require => Vcsrepo[$gush_location],
  } ->
  file { 'symlink gush':
    ensure => link,
    path   => '/usr/bin/gush',
    target => "${gush_location}/bin/gush",
  }

This will nicely plug gush into your vagrant and you just have to reprovision with:

vagrant provision

I also provisioned the dev popular script but via the Vagrantfile, if you think is best to provision this custom file via a pp file then set a good justification for it on the comments. I think it is ok for now and here it is:

// Vagrantfile

   if !data['vagrant']['host'].nil?
     config.vagrant.host = data['vagrant']['host'].gsub(':', '').intern
   end
+
+  config.vm.provision :shell, :path => 'puphpet/shell/dev.sh'
 end

And place the dev file inside ${VAGRANT_CORE_FOLDER}/files/dot/dev:

#!/usr/bin/env bash

bldr=$(which bldr)
 
if [ -x "$bldr" ] ; then
    $bldr install
    $bldr run $1
else
    if [ ! -f ./bldr.phar ]; then
        curl -sS http://bldr.io/installer | php
    fi
 
    ./bldr.phar install
    ./bldr.phar run $1
fi

And also the shell under ‘puphpet/shell/dev.sh’:

#!/bin/bash

VAGRANT_CORE_FOLDER=$(cat '/.puphpet-stuff/vagrant-core-folder.txt')

sudo su
chmod +x "${VAGRANT_CORE_FOLDER}/files/dot/dev"
cp "${VAGRANT_CORE_FOLDER}/files/dot/dev" '/usr/local/bin/dev'

The last trick is with puppet-librarian which you can ruby install it. This tool is like a composer but for modules. So all that is under vagrant/puphpet/puppet/modules should be added to .gitignore on your project and you just need to run puppet-librarian install like in composer.

/vagrant/puphpet/puppet/.librarian
/vagrant/puphpet/puppet/.tmp
/vagrant/puphpet/puppet/modules

In order to get the right sha1 to which your working puppet was working then just switch to the right Puppetfile replacing it with:

forge "https://forgeapi.puppetlabs.com"
 
mod 'puppetlabs/apache',
    :git => 'https://github.com/puphpet/puppetlabs-apache.git',
    :ref => 'f12483b'
mod 'puppetlabs/apt',
    :git => 'https://github.com/puppetlabs/puppetlabs-apt.git',
    :ref => '1.4.2'
mod 'puphpet/beanstalkd',
    :git => 'https://github.com/puphpet/puppet-beanstalkd.git',
    :ref => '5a530ff'
mod 'tPl0ch/composer',
    :git => 'https://github.com/tPl0ch/puppet-composer.git',
    :ref => '1.2.1'
mod 'puppetlabs/concat',
    :git => 'https://github.com/puppetlabs/puppetlabs-concat.git',
    :ref => '1.1.0'
mod 'elasticsearch/elasticsearch',
    :git => 'https://github.com/puphpet/puppet-elasticsearch.git',
    :ref => '0.2.2'
mod 'garethr/erlang',
    :git => 'https://github.com/garethr/garethr-erlang.git',
    :ref => '91d8ec73c3'
mod 'puppetlabs/firewall',
    :git => 'https://github.com/puppetlabs/puppetlabs-firewall.git',
    :ref => '1.1.1'
mod 'actionjack/mailcatcher',
    :git => 'https://github.com/puphpet/puppet-mailcatcher.git',
    :ref => 'dcc8c3d357'
mod 'puppetlabs/mongodb',
    :git => 'https://github.com/puppetlabs/puppetlabs-mongodb.git',
    :ref => '0.8.0'
mod 'puppetlabs/mysql',
    :git => 'https://github.com/puppetlabs/puppetlabs-mysql.git',
    :ref => '2.3.1'
mod 'jfryman/nginx',
    :git => 'https://github.com/jfryman/puppet-nginx.git',
    :ref => 'v0.0.9'
mod 'puppetlabs/ntp',
    :git => 'https://github.com/puppetlabs/puppetlabs-ntp.git',
    :ref => '3.0.4'
mod 'puphpet/php',
    :git => 'https://github.com/puphpet/puppet-php.git',
    :ref => 'a1dad7828d'
mod 'puppetlabs/postgresql',
    :git => 'https://github.com/puppetlabs/puppetlabs-postgresql.git',
    :ref => '3.3.3'
mod 'puphpet/puphpet',
    :git => 'https://github.com/puphpet/puppet-puphpet.git',
    :ref => '9253681'
mod 'example42/puppi',
    :git => 'https://github.com/example42/puppi.git',
    :ref => 'v2.1.9'
mod 'daenney/pyenv',
    :git => 'https://github.com/puphpet/puppet-pyenv.git',
    :ref => '062ae72'
mod 'puppetlabs/rabbitmq',
    :git => 'https://github.com/puppetlabs/puppetlabs-rabbitmq.git',
    :ref => '5ce33f4968'
mod 'puphpet/redis',
    :git => 'https://github.com/puphpet/puppet-redis.git',
    :ref => 'd9b3b23b0c'
mod 'maestrodev/rvm'
mod 'puppetlabs/sqlite',
    :git => 'https://github.com/puppetlabs/puppetlabs-sqlite.git',
    :ref => 'v0.0.1'
mod 'petems/swap_file',
    :git => 'https://github.com/petems/puppet-swap_file.git',
    :ref => '39582afda5'
mod 'nanliu/staging',
    :git => 'https://github.com/nanliu/puppet-staging.git',
    :ref => '0.4.0'
mod 'ajcrowe/supervisord',
    :git => 'https://github.com/puphpet/puppet-supervisord.git',
    :ref => '17643f1'
mod 'puppetlabs/stdlib'
mod 'puppetlabs/vcsrepo',
    :git => 'https://github.com/puppetlabs/puppetlabs-vcsrepo.git',
    :ref => '0.2.0'
mod 'example42/yum',
    :git => 'https://github.com/example42/puppet-yum.git',
    :ref => 'v2.1.10'

That is it! Encouragements in all good! and give retweets please!