Skip to content

Instantly share code, notes, and snippets.

@Oliv4945
Last active February 4, 2016 23:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Oliv4945/04bb59136b15e5fbfa78 to your computer and use it in GitHub Desktop.
Save Oliv4945/04bb59136b15e5fbfa78 to your computer and use it in GitHub Desktop.
Ansible script to compile and use Go with gvm
---
- hosts: all
#gather_facts: no
sudo: no
user: pi
tasks:
- name : install GVM
shell: curl -s -S -L https://raw.githubusercontent.com/moovweb/gvm/master/binscripts/gvm-installer | bash -
- name : Change GVM rights
file: path=/home/pi/.gvm/scripts/gvm mode=0744
- name : Install go1.4.3
shell: source /home/pi/.gvm/scripts/gvm && gvm install go1.4.3
args:
executable: /bin/bash
- name : Install go1.5.2
shell: source /home/pi/.gvm/scripts/gvm && gvm use go1.4.3 --default && gvm install go1.5.2
args:
executable: /bin/bash
- name : Use go1.5.2
shell: source /home/pi/.gvm/scripts/gvm && gvm use go1.5.2 && go [file to compile]
args:
executable: /bin/bash
---
- hosts: all
#gather_facts: no
sudo: no
user: pi
tasks:
- name : Create Influx directory
file: path=~/go/src/github.com/influxdb/influxdb
state=directory
recurse=yes
- name : Get Influx
git: repo=https://github.com/influxdata/influxdb.git
dest=~/go/src/github.com/influxdb/influxdb
- name : Compile InfluxDB
shell: source ~/.gvm/scripts/gvm && gvm use go1.4.3 && export GOPATH=~/go && go get -f -u -t ./...
args:
executable: /bin/bash
chdir: ~/go/src/github.com/influxdb/
environment:
GOPATH: ~/go
---
# Tested with Ansible 1.7.2, not working...to much conflicts version between Ruby and dependancies.
# Best way is to avoid the generation of a *.deb package
- hosts: all
#gather_facts: no
sudo: no
user: pi
tasks:
- name : Get Grafana & dependancies
shell: source ~/.gvm/scripts/gvm && gvm use go1.5.2 && export GOPATH=~/go
&& go get github.com/grafana/grafana
args:
executable: /bin/bash
- name : Install godep
shell: source ~/.gvm/scripts/gvm && gvm use go1.5.2 && export GOPATH=~/go
&& go run build.go setup
args:
executable: /bin/bash
chdir: ~/go/src/github.com/grafana/grafana
- name : Godep restore
shell: source ~/.gvm/scripts/gvm && gvm use go1.5.2 && export GOPATH=~/go
&& ~/go/bin/godep restore
args:
executable: /bin/bash
chdir: ~/go/src/github.com/grafana/grafana
- name : Force grunt to bypass PhantomJS issues - Warning for arm only !!
shell: 'sed -i -e "s/grunt(\"release\")/grunt(\"--force\",\"release\")/g"
build.go'
args:
chdir: ~/go/src/github.com/grafana/grafana
- name : Remove karma-phantomjs-launcher from package.json
shell: 'sed -i -e "s/\"karma-phantomjs-launcher\": \"0.2.1\",//g" package.
json'
args:
chdir: ~/go/src/github.com/grafana/grafana
- name : Remove PhantomJS from package.json
shell: 'sed -i -e "s/\"phantomjs\": \"^1.9.19\",//g" package.json'
args:
chdir: ~/go/src/github.com/grafana/grafana
- name : Install JS dependancies
npm: path=/home/{{ ansible_ssh_user }}/go/src/github.com/grafana/grafana
- name : Install grunt
npm: name=grunt-cli global=yes
sudo: yes
- name : run Grunt
shell: grunt --force
args:
chdir: ~/go/src/github.com/grafana/grafana
- name : Build Grafana
shell: source ~/.gvm/scripts/gvm && gvm use go1.5.2 && export GOPATH=~/go
&& go run build.go build
args:
executable: /bin/bash
chdir: ~/go/src/github.com/grafana/grafana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment