Merge pull request #16 from realraum/openwrt-image
[noc.git] / ansible / tuer.yml
1 ---
2 - hosts: torwaechter
3   connection: local
4   pre_tasks:
5     - name: Create go directories
6       file:
7         path: .cache/openwrt/tuer/{{ item }}
8         state: directory
9       with_items: [ gopath, gocache ]
10
11     - name: Clone necessary git repositories
12       git:
13         repo: https://github.com/realraum/{{ item }}.git
14         dest: .cache/openwrt/tuer/{{ item }}
15         update: True
16       with_items: [ door_and_sensors ]
17
18     - name: Download dependencies
19       command: go get -d ./...
20       args:
21         chdir: .cache/openwrt/tuer/door_and_sensors/{{ item }}
22       environment:
23         GOCACHE: "{{ playbook_dir }}/.cache/openwrt/tuer/gocache"
24         GOPATH:  "{{ playbook_dir }}/.cache/openwrt/tuer/gopath"
25       with_items: [ door_client, door_daemon, update-keys ]
26
27     - name: Cross-compile Go binaries
28       command: go build -ldflags "-s"
29       args:
30         chdir: .cache/openwrt/tuer/door_and_sensors/{{ item }}
31       environment:
32         GOCACHE: "{{ playbook_dir }}/.cache/openwrt/tuer/gocache"
33         GOPATH:  "{{ playbook_dir }}/.cache/openwrt/tuer/gopath"
34         GO386: 387
35         CGO_ENABLED: 0
36         GOOS: linux
37         GOARCH: 386
38       with_items: [ door_client, door_daemon, update-keys ]
39
40   roles:
41     - role: openwrt-image
42       delegate_to: localhost