From 413ae77b4f8eacf25f2a4165168b215f5f6cc5e6 Mon Sep 17 00:00:00 2001 From: Darren Coxall Date: Wed, 24 Dec 2014 13:33:29 +0000 Subject: [PATCH] Install git and mercurial To make "go get" work in most cases you need either git or mercurial installed to clone the dependencies. Now the golang class will install these but the requirement to update aptitude (on debian based machines) is not a concern for the golang class and so is handled outside of the class. --- README.md | 2 +- manifests/init.pp | 16 ++++++++++++++-- modules/golang/manifests/init.pp | 12 ++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9cfc02b..ea23d99 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ hello ## Choosing golang version This repo is hardcoded to use 1.4 although this can easily be changed after cloning. If you want to use another version simply -change the `$version` parameter in `manifests/init.pp`. The version string is taken from the +set the `$version` parameter when calling the class. The version string is taken from the [golang downloads list](http://golang.org/dl/). Once changed you can either call `vagrant up` if you haven't already setup the vagrant box or `vagrant provision` if the machine is already up. diff --git a/manifests/init.pp b/manifests/init.pp index 76e43dc..fa85048 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -1,3 +1,15 @@ -class { "golang": - version => "1.4" +stage { "prepare": + before => Stage["main"], +} + +class setup { + exec { "update-aptitude": + command => "/usr/bin/apt-get update -y", + } +} + +class { + "setup": + stage => prepare; + "golang":; } diff --git a/modules/golang/manifests/init.pp b/modules/golang/manifests/init.pp index cec9e6d..2472ad2 100644 --- a/modules/golang/manifests/init.pp +++ b/modules/golang/manifests/init.pp @@ -26,4 +26,16 @@ class golang ( $version = "1.4" ) { unless => "/bin/grep -q GOPATH /home/vagrant/.profile ; /usr/bin/test $? -eq 0" } + if ! defined(Package["git"]) { + package { "git": + ensure => present, + } + } + + if ! defined(Package["mercurial"]) { + package { "mercurial": + ensure => present, + } + } + }