tuer: Add missing packages
[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_output_image_suffixes:
47           - combined-ext4.img.gz
48           - combined-squashfs.img
49         openwrt_packages_remove:
50           - ppp
51           - ppp-mod-pppoe
52           - dnsmasq
53           - firewall
54           - odhcpd
55         openwrt_packages_add:
56           - flashrom
57           - haveged
58           - htop
59           - hwclock
60           - ip
61           - less
62           - nano
63           - tcpdump
64         openwrt_packages_extra:
65           - "-dropbear"
66           - git
67           - kmod-usb-acm
68           - openssh-server
69           - screen
70           - sudo
71           - usbutils
72
73         openwrt_mixin:
74           # Go binaries
75           /usr/local/bin/door_client:
76             mode: '0755'
77             file: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/door_client/door_client"
78           /usr/local/bin/door_daemon:
79             mode: '0755'
80             file: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/door_daemon/door_daemon"
81           /usr/local/bin/update-keys:
82             mode: '0755'
83             file: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/update-keys/update-keys"
84
85           /usr/local/bin/authorized_keys.sh:
86             mode: '0755'
87             file: "{{ playbook_dir }}/files/tuer/authorized_keys.sh"
88
89           /usr/local/bin/update-keys-from-stdin.sh:
90             mode: '0755'
91             file: "{{ playbook_dir }}/files/tuer/update-keys-from-stdin.sh"
92
93           /etc/ssh/sshd_config:
94             content: |-
95               Port 22000
96
97               AllowUsers root tuerctl tuergit
98               AuthenticationMethods publickey
99               AuthorizedKeysFile /etc/ssh/authorized_keys.d/%u
100
101               AllowAgentForwarding no
102               AllowTcpForwarding no
103               X11Forwarding no
104               UsePrivilegeSeparation sandbox
105
106               Match User tuerctl
107                 AuthorizedKeysFile /dev/null
108                 AuthorizedKeysCommand /usr/local/bin/authorized_keys.sh
109                 AuthorizedKeysCommandUser tuergit
110
111
112           /etc/ssh/authorized_keys.d/root:
113             content: |-
114               {% for key in noc_ssh_keys %}
115               {{ key }}
116               {% endfor %}
117
118           /etc/ssh/authorized_keys.d/tuergit:
119             content: |-
120               {% for key in noc_ssh_keys %}
121               {{ key }}
122               {% endfor %}
123
124         openwrt_uci:
125           system:
126             - name: system
127               options:
128                 hostname: '{{ inventory_hostname }}'
129                 timezone: 'CET-1CEST,M3.5.0,M10.5.0/3'
130                 ttylogin: '0'
131                 log_size: '64'
132                 urandom_seed: '0'
133
134             - name: timeserver 'ntp'
135               options:
136                 enabled: '1'
137                 enable_server: '0'
138                 server:
139                   - '0.lede.pool.ntp.org'
140                   - '1.lede.pool.ntp.org'
141                   - '2.lede.pool.ntp.org'
142                   - '3.lede.pool.ntp.org'
143
144           network:
145             - name: globals 'globals'
146               options:
147                 ula_prefix: fdc9:e01f:83db::/48
148
149             - name: interface 'loopback'
150               options:
151                 ifname: lo
152                 proto: static
153                 ipaddr: 127.0.0.1
154                 netmask: 255.0.0.0
155
156             - name: interface 'lan'
157               options:
158                 ifname: eth0
159                 accept_ra: 0
160                 proto: static
161                 ipaddr: 192.168.33.7
162                 netmask: 255.255.255.0
163                 gateway: 192.168.33.1
164                 dns: 192.168.33.1
165                 dns_search: realraum.at
166
167
168         openwrt_mounts:
169           - path: /run
170             src: none
171             fstype: tmpfs
172             opts: nosuid,nodev,noexec,noatime
173
174         openwrt_users:
175           tuerd: {}
176           tuergit:
177             home:  /home/tuergit
178             shell: /usr/bin/git-shell
179           tuerctl:
180             shell: /bin/false # TODO fixme