From 30632f4aad6abf82b51a51cd9f9f5850de01df47 Mon Sep 17 00:00:00 2001 From: Darren Coxall Date: Thu, 2 May 2013 08:46:45 +0100 Subject: [PATCH] Setup recommended golang environment --- .gitignore | 1 + Vagrantfile | 12 ++++++++++++ bin/.gitkeep | 0 manifests/init.pp | 3 +++ modules/golang/manifests/init.pp | 29 +++++++++++++++++++++++++++++ pkg/.gitkeep | 0 src/hello/hello.go | 7 +++++++ 7 files changed, 52 insertions(+) create mode 100644 Vagrantfile create mode 100644 bin/.gitkeep create mode 100644 manifests/init.pp create mode 100644 modules/golang/manifests/init.pp create mode 100644 pkg/.gitkeep create mode 100644 src/hello/hello.go diff --git a/.gitignore b/.gitignore index 0026861..733e394 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ _cgo_export.* _testmain.go *.exe +.vagrant diff --git a/Vagrantfile b/Vagrantfile new file mode 100644 index 0000000..5a554d4 --- /dev/null +++ b/Vagrantfile @@ -0,0 +1,12 @@ +# -*- mode: ruby -*- +# vi: set ft=ruby : + +Vagrant::Config.run do |config| + config.vm.box = "debian-607-x64-vbox4210" + config.vm.box_url = "http://puppet-vagrant-boxes.puppetlabs.com/debian-607-x64-vbox4210.box" + config.vm.provision :puppet do |puppet| + puppet.module_path = "modules" + puppet.manifests_path = "manifests" + puppet.manifest_file = "init.pp" + end +end diff --git a/bin/.gitkeep b/bin/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/manifests/init.pp b/manifests/init.pp new file mode 100644 index 0000000..d77fbfc --- /dev/null +++ b/manifests/init.pp @@ -0,0 +1,3 @@ +class { "golang": + version => "1.1rc1" +} diff --git a/modules/golang/manifests/init.pp b/modules/golang/manifests/init.pp new file mode 100644 index 0000000..83ce338 --- /dev/null +++ b/modules/golang/manifests/init.pp @@ -0,0 +1,29 @@ +class golang ( $version = "1.0.3" ) { + + exec { "download-golang": + command => "/usr/bin/wget -O /usr/local/src/go$version.linux-amd64.tar.gz https://go.googlecode.com/files/go$version.linux-amd64.tar.gz", + creates => "/usr/local/src/go$version.linux-amd64.tar.gz" + } + + exec { "remove-previous-version": + command => "/bin/rm -r /usr/local/go", + onlyif => "/usr/bin/test -d /usr/local/go", + before => Exec["unarchive-golang-tools"] + } + + exec { "unarchive-golang-tools": + command => "/bin/tar -C /usr/local -xzf /usr/local/src/go$version.linux-amd64.tar.gz", + require => Exec["download-golang"] + } + + exec { "setup-path": + command => "/bin/echo 'export PATH=/vagrant/bin:/usr/local/go/bin:\$PATH' >> /home/vagrant/.profile", + unless => "/bin/grep -q /usr/local/go /home/vagrant/.profile ; /usr/bin/test $? -eq 0" + } + + exec { "setup-workspace": + command => "/bin/echo 'export GOPATH=/vagrant' >> /home/vagrant/.profile", + unless => "/bin/grep -q GOPATH /home/vagrant/.profile ; /usr/bin/test $? -eq 0" + } + +} diff --git a/pkg/.gitkeep b/pkg/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/src/hello/hello.go b/src/hello/hello.go new file mode 100644 index 0000000..c2fbf9c --- /dev/null +++ b/src/hello/hello.go @@ -0,0 +1,7 @@ +package main + +import "fmt" + +func main() { + fmt.Printf("hello, world\n") +}