tuer: Add stuff for tuergit
[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           - openssh-server
67           - git
68           - sudo
69
70         openwrt_mixin:
71           # Go binaries
72           /usr/local/bin/door_client:
73             mode: '0755'
74             file: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/door_client/door_client"
75           /usr/local/bin/door_daemon:
76             mode: '0755'
77             file: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/door_daemon/door_daemon"
78           /usr/local/bin/update-keys:
79             mode: '0755'
80             file: "{{ playbook_dir }}/.cache/openwrt/tuer/door_and_sensors/update-keys/update-keys"
81
82           /usr/local/bin/authorized_keys.sh:
83             mode: '0755'
84             file: "{{ playbook_dir }}/files/tuer/authorized_keys.sh"
85
86           /usr/local/bin/update-keys-from-stdin.sh:
87             mode: '0755'
88             file: "{{ playbook_dir }}/files/tuer/update-keys-from-stdin.sh"
89
90           /etc/ssh/sshd_config:
91             content: |-
92               Port 22000
93
94               AllowUsers root tuerctl tuergit
95               AuthenticationMethods publickey
96               AuthorizedKeysFile /etc/ssh/authorized_keys.d/%u
97
98               AllowAgentForwarding no
99               AllowTcpForwarding no
100               X11Forwarding no
101               UsePrivilegeSeparation sandbox
102
103               Match User tuerctl
104                 AuthorizedKeysFile /dev/null
105                 AuthorizedKeysCommand /usr/local/bin/authorized_keys.sh
106                 AuthorizedKeysCommandUser tuergit
107
108
109           /etc/ssh/authorized_keys.d/root:
110             content: |-
111               {% for key in noc_ssh_keys %}
112               {{ key }}
113               {% endfor %}
114
115           /etc/ssh/authorized_keys.d/tuergit:
116             content: |-
117               {% for key in noc_ssh_keys %}
118               {{ key }}
119               {% endfor %}
120
121         openwrt_uci:
122           network:
123             - name: globals 'globals'
124               options:
125                 ula_prefix: fdc9:e01f:83db::/48
126
127             - name: interface 'loopback'
128               options:
129                 ifname: lo
130                 proto: static
131                 ipaddr: 127.0.0.1
132                 netmask: 255.0.0.0
133
134             - name: interface 'lan'
135               options:
136                 ifname: eth0
137                 accept_ra: 0
138                 proto: static
139                 ipaddr: 192.168.33.7
140                 netmask: 255.255.255.0
141                 gateway: 192.168.33.1
142                 dns: 192.168.33.1
143                 dns_search: realraum.at
144
145
146         openwrt_mounts:
147           - path: /run
148             src: none
149             fstype: tmpfs
150             opts: nosuid,nodev,noexec,noatime
151
152         openwrt_users:
153           tuerd: {}
154           tuergit:
155             home:  /home/tuergit
156             shell: /usr/bin/git-shell
157           tuerctl:
158             shell: /bin/false # TODO fixme