cosmetic changes
[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
43       vars:
44         openwrt_arch: x86
45         openwrt_target: geode
46         openwrt_packages_remove:
47           - ppp
48           - ppp-mod-pppoe
49           - dnsmasq
50           - firewall
51           - odhcpd
52         openwrt_packages_add:
53           - flashrom
54           - haveged
55           - htop
56           - hwclock
57           - ip
58           - less
59           - nano
60           - tcpdump
61         openwrt_packages_extra:
62           - git
63
64         openwrt_mixin:
65           files:
66             # Go binaries
67             /usr/local/bin/door_client: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/door_client/door_client"
68             /usr/local/bin/door_daemon: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/door_daemon/door_daemon"
69             /usr/local/bin/update-keys: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/update-keys/update-keys"
70
71           content:
72             /etc/config/network: |
73               config interface 'loopback'
74                 option ifname 'lo'
75                 option proto 'static'
76                 option ipaddr '127.0.0.1'
77                 option netmask '255.0.0.0'
78               
79               config globals 'globals'
80                 option ula_prefix 'fdc9:e01f:83db::/48'
81               
82               config interface 'lan'
83                 option ifname 'eth0'
84                 option accept_ra '0'
85                 option proto 'static'
86                 option ipaddr  '192.168.33.7'
87                 option netmask '255.255.255.0'
88                 option gateway '192.168.33.1'
89                 option dns     '192.168.33.1'
90                 option dns_search 'realraum.at'
91
92             /etc/config/dropbear: |
93               config dropbear
94                 option PasswordAuth 'on'
95                 option RootPasswordAuth 'off'
96                 option Port '22000'
97
98             /etc/dropbear/authorized_keys: |-
99               {% for key in noc_ssh_keys %}
100               key
101               {% endfor %}