Tuer firmware (WIP)
[noc.git] / ansible / tuer.yml
1 - hosts: torwaechter
2   connection: local
3   pre_tasks:
4     - name: Create go directories
5       file:
6         path: .cache/openwrt/tuer/{{ item }}
7         state: directory
8       with_items: [ gopath, gocache ]
9
10     - name: Clone necessary git repositories
11       git:
12         repo: https://github.com/realraum/{{ item }}.git
13         dest: .cache/openwrt/tuer/{{ item }}
14         update: True
15       with_items: [ door_and_sensors ]
16
17     - name: Download dependencies
18       command: go get -d ./...
19       args:
20         chdir: .cache/openwrt/tuer/door_and_sensors/{{ item }}
21       environment:
22         GOCACHE: "{{ playbook_dir }}/.cache/openwrt/tuer/gocache"
23         GOPATH:  "{{ playbook_dir }}/.cache/openwrt/tuer/gopath"
24       with_items: [ door_client, door_daemon, update-keys ]
25
26     - name: Cross-compile Go binaries
27       command: go build -ldflags "-s"
28       args:
29         chdir: .cache/openwrt/tuer/door_and_sensors/{{ item }}
30       environment:
31         GOCACHE: "{{ playbook_dir }}/.cache/openwrt/tuer/gocache"
32         GOPATH:  "{{ playbook_dir }}/.cache/openwrt/tuer/gopath"
33         GO386: 387
34         CGO_ENABLED: 0
35         GOOS: linux
36         GOARCH: 386
37       with_items: [ door_client, door_daemon, update-keys ]
38
39   roles:
40     - role: openwrt-image
41       delegate_to: localhost
42       vars:
43         openwrt_arch: x86
44         openwrt_target: geode
45         openwrt_packages_remove:
46           - ppp
47           - ppp-mod-pppoe
48           - dnsmasq
49           - firewall
50           - odhcpd
51         openwrt_packages_add:
52           - flashrom
53           - haveged
54           - htop
55           - hwclock
56           - ip
57           - less
58           - nano
59           - tcpdump
60         openwrt_packages_extra:
61           - git
62
63         openwrt_mixin:
64           files:
65             # Go binaries
66             /usr/local/bin/door_client: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/door_client/door_client"
67             /usr/local/bin/door_daemon: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/door_daemon/door_daemon"
68             /usr/local/bin/update-keys: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/update-keys/update-keys"
69
70           content:
71             /etc/config/network: |
72               config interface 'loopback'
73                 option ifname 'lo'
74                 option proto 'static'
75                 option ipaddr '127.0.0.1'
76                 option netmask '255.0.0.0'
77               
78               config globals 'globals'
79                 option ula_prefix 'fdc9:e01f:83db::/48'
80               
81               config interface 'lan'
82                 option ifname 'eth0'
83                 option accept_ra '0'
84                 option proto 'static'
85                 option ipaddr  '192.168.33.7'
86                 option netmask '255.255.255.0'
87                 option gateway '192.168.33.1'
88                 option dns     '192.168.33.1'
89                 option dns_search 'realraum.at'
90
91             /etc/config/dropbear: |
92               config dropbear
93                 option PasswordAuth 'on'
94                 option RootPasswordAuth 'off'
95                 option Port '22000'
96
97             /etc/dropbear/authorized_keys: |-
98               {% for key in noc_ssh_keys %}
99               key
100               {% endfor %}