-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.yml
154 lines (129 loc) · 5.22 KB
/
setup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---
- hosts: "{{target|default('all')}}"
become: true
become_user: "{{ deployment_user|default('vagrant') }} -i"
become_method: "sudo"
vars:
build_variant: false
kapacitor_checkout: master
influxdb_checkout: master
projects:
- project: kapacitor
checkout: "{{kapacitor_checkout}}"
- project: influxdb
checkout: "{{influxdb_checkout}}"
roles:
- role: angstwad.docker_ubuntu
become_user: root
docker_group_members: ["{{deployment_user|default('vagrant')}}"]
- role: joshualund.golang
go_tarball: go1.4.3.linux-amd64.tar.gz
go_tarball_checksum: sha1:332b64236d30a8805fc8dd8b3a269915b4c507fe
become_user: root
tasks:
- include: tasks/sync.yml
- name: Add ssh agent line to sudoers
become_user: root
lineinfile:
dest: /etc/sudoers
state: present
regexp: SSH_AUTH_SOCK
line: Defaults env_keep += "SSH_AUTH_SOCK"
tags: ["init-sudo"]
- block:
- name: "clone influxdb-docker"
git: repo=https://github.com/influxdata/influxdb-docker.git
dest=~/influxdb-docker
- name: "clone kapacitor-docker"
git: repo=https://github.com/influxdata/kapacitor-docker.git
dest=~/kapacitor-docker
- name: "clone influxdb"
git: repo=https://github.com/influxdata/influxdb.git
dest=~/go/src/github.com/influxdata/influxdb
- name: "clone kapacitor"
git: repo=https://github.com/influxdata/kapacitor.git
dest=~/go/src/github.com/influxdata/kapacitor
tags: ["clone"]
- block:
- name: "make base influxdb image"
docker_image:
path=/home/{{ansible_user}}/influxdb-docker/0.12/
name=influxdb
state=present
tag=latest
- name: "make base kapacitor image"
docker_image:
path=/home/{{ansible_user}}/kapacitor-docker/0.12/
name=kapacitor
state=present
tag=latest
- name: "initialise default copies"
shell: |
docker run --rm -v $(pwd)/services/build:/build --entrypoint=/bin/sh influxdb:latest -c 'cp /usr/bin/influx /build'
docker run --rm -v $(pwd)/services/build:/build --entrypoint=/bin/sh influxdb:latest -c 'cp /usr/bin/influxd /build'
docker run --rm -v $(pwd)/services/build:/build --entrypoint=/bin/sh kapacitor:latest -c 'cp /usr/bin/kapacitor /build'
docker run --rm -v $(pwd)/services/build:/build --entrypoint=/bin/sh kapacitor:latest -c 'cp /usr/bin/kapacitord /build'
- block:
- name: "link the influx client"
file: path=/usr/bin/influx src=/home/{{ansible_user}}/services/build/influx state=link
- name: "link the kapacitor client"
file: path=/usr/bin/kapacitor src=/home/{{ansible_user}}/services/build/kapacitor state=link
tags: ["links"]
become_user: root
- block:
- name: "sync with source"
shell: |
cd $GOPATH/src/github.com/influxdata/{{item.project}} &&
git fetch origin &&
git checkout {{item.checkout}}
with_items: "{{projects}}"
- name: "build influxdb"
shell: |
pushd ~/go/src/github.com/influxdata/influxdb &&
go get -d ./... &&
popd &&
mkdir -p services/build &&
go build -o services/build/influxd github.com/influxdata/influxdb/cmd/influxd &&
go build -o services/build/influx github.com/influxdata/influxdb/cmd/influx
args:
executable: /bin/bash
- name: "build kapacitor"
shell: |
OLDPWD=$(pwd) &&
mkdir -p services/build &&
pushd ~/go/src/github.com/influxdata/kapacitor &&
go get -d ./... &&
docker run -it -v ${OLDPWD}/services/build:/app/build -v "${GOPATH}":/gopath -v "$(pwd)":/app -e "GOPATH=/gopath" -w /app golang:1.6 sh -c 'go build --ldflags="-s" -o build/kapacitord ./cmd/kapacitord'
docker run -it -v ${OLDPWD}/services/build:/app/build -v "${GOPATH}":/gopath -v "$(pwd)":/app -e "GOPATH=/gopath" -w /app golang:1.6 sh -c 'go build --ldflags="-s" -o build/kapacitor ./cmd/kapacitor'
args:
executable: /bin/bash
tags: recompile
when: build_variant
- block:
- name: "install csv tools"
shell: |
go get -d github.com/wildducktheories/go-csv
go install github.com/wildducktheories/go-csv/...
- name: "build composition"
shell: |
docker-compose -f ~/services/docker-compose.yml build
tags: ["build", "recompile"]
- name: "restart composition after variant build"
shell: |
docker-compose -f ~/services/docker-compose.yml down
docker-compose -f ~/services/docker-compose.yml up -d
when: build_variant
tags: ["recompile"]
- block:
- name: "start"
shell: |
cd ~/services &&
docker-compose up -d &&
sleep 5
tags: ["start"]
- block:
- name: "Load the sample data (load-data)"
shell: |
influx -execute 'create database sampledb' &&
curl --data-binary @- "http://localhost:8086/write?db=sampledb&precision=ns" < test-data/load.influx
tags: ["load-data"]