Ask Your Question

Install apecific version of Apache, PHP and MySQL in with a Vagrant Puppet Provisioner?

asked 2016-12-23 10:49:01 -0500

leeand00 gravatar image

On the Puppet Blog I found the following post on creating a Puppet / Vagrant box; and I followed the directions with the exception of Step 2 where I decided to use the ubuntu/trusty64box instead.

My goal is to setup a LAMP development environment with the following versions of the programs in the LAMP Stack:

  • MySQL: 5.2.38
  • PHP: 5.6.16
  • Apache: 2.2.31 match that of the host of the website.

Though I'd prefer to use the standard puppet labs modules (apache, mysql) for these, I decided to go with the versions in the blog post since most of it is already setup and can just be cloned from github (though it does look a little old to me, 2013 was a while ago).

I thought this would be pretty easy to do; that I could just change the version numbers in the various manifest files from the github clone, for example in puppet-lamp-stack/modules/apache/manifests/init.pp, I changed ensure => present to ensure => '2.2.31:

class apache {

  # install apache
  package { "apache2":
    ensure => '2.2.31'
    require => Exec["apt-get update"]

and in puppet-lamp-stack/modules/mysql/manifests/init.pp, I changed ensure => present to ensure => '5.2.38:

class mysql {

  # root mysql password
  $mysqlpw = "d3v0p5"

  # install mysql server
  package { "mysql-server":
    ensure => '5.2.38',
    require => Exec["apt-get update"]

But then when I looked to do the same thing for php in puppet-lamp-stack/modules/php/manifests/init.pp, I noticed the format was completely different, and not specific to just php:

class php {

  # package install list
  $packages = [

  package { $packages:
    ensure => present,
    require => Exec["apt-get update"]

So how do I know that I would be getting the right version of these packages if I changed ensure => present to ensure => 5.6.16?

Or should I be setting this up in some other way? Also am I actually using the puppet-labs standard versions of these packages in the code I cloned?

edit retag flag offensive close merge delete


Should I be using some other vagrant box? Like Scotchbox or VVV?

leeand00 gravatar imageleeand00 ( 2016-12-23 10:51:30 -0500 )edit

2 answers

Sort by » oldest newest most voted

answered 2016-12-23 15:59:26 -0500

lupin gravatar image

You set the ensure => 'latest it will install latest of version of the packages. If you want specific version then you declare it in the value of your $packages variable. ie. php5-x.x.

edit flag offensive delete link more

answered 2017-01-06 04:47:37 -0500

HBlock gravatar image

Since it looks like the packages in your array all share the same versioning, you can change the ensure present, as suggested. Otherwise you'd have to split the array and use more than one package resource, or (at least in puppet 3) convert into a hash and use create_resources

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower


Asked: 2016-12-23 10:49:01 -0500

Seen: 89 times

Last updated: Jan 06