-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenafs-appliance.yml
281 lines (253 loc) · 8.11 KB
/
openafs-appliance.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
#
# Ansible playbook to configure an OpenAFS appliance.
#
# SPDX-FileCopyrightText: 2023 Carnegie Mellon University
# SPDX-License-Identifier: GPL-2.0-only
#
- hosts: image
vars:
debug_image: false # set this to true to allow passwordless root login
hostname: openafs
kerberos:
realm: ANDREW.CMU.EDU
openafs:
cell: andrew.cmu.edu
samba:
workgroup: "OPENAFS"
samba_rebuild:
root: "http://coda.cs.cmu.edu/~jaharkes/samba-rebuild"
coda:
enabled: false
realm: testserver.coda.cs.cmu.edu
iface:
name: eth0
tasks:
#####################################
- name: ensure required software packages are installed
ansible.builtin.apt:
pkg:
- avahi-utils
- chrony
- krb5-user
# openafs
- openafs-client
- openafs-krb5
# samba
- samba
# webauth
- caddy
- gunicorn
- python3-flask
#####################################
- name: configure system hostname/networking
tags: config
block:
- name: set hostname
ansible.builtin.copy:
content: "{{ hostname }}"
dest: /etc/hostname
- name: unset root password
ansible.builtin.replace:
path: /etc/shadow
regexp: '^root:[^:]*:(.*)$'
replace: 'root::\1'
when: debug_image | bool
- name: configure networking
ansible.builtin.copy:
content: |
auto {{ iface.name }}
allow-hotplug {{ iface.name }}
iface {{ iface.name }} inet dhcp
dest: /etc/network/interfaces.d/wired
#####################################
- name: configure Kerberos
tags: config
block:
- name: add CS.CMU.EDU realm mapping to krb5.config
ansible.builtin.lineinfile:
path: /etc/krb5.conf
regexp: '^\s*\.cs\.cmu\.edu = CS\.CMU\.EDU$'
line: " .cs.cmu.edu = CS.CMU.EDU"
- name: set default kerberos realm
ansible.builtin.replace:
path: /etc/krb5.conf
regexp: '^(.*default_realm[^=]*=).*$'
replace: '\1 {{ kerberos.realm }}'
#####################################
- name: configure OpenAFS
tags: config
block:
- name: configure OpenAFS | client
ansible.builtin.copy:
content: |
AFS_CLIENT=true
AFS_AFSDB=true
AFS_CRYPT=true
AFS_DYNROOT=Yes
AFS_FAKESTAT=true
dest: /etc/openafs/afs.conf.client
- name: configure OpenAFS | increase cache size
ansible.builtin.copy:
content: "/afs:/var/cache/openafs:1000000"
dest: /etc/openafs/cacheinfo
- name: set local AFS cell
ansible.builtin.copy:
content: "{{ openafs.cell }}"
dest: /etc/openafs/ThisCell
- name: update CellServDB to a more recent version
ansible.builtin.copy:
src: CellServDB
dest: /etc/openafs/CellServDB
- name: add {andrew,cs,ece} cell shortcuts
ansible.builtin.copy:
content: |
andrew.cmu.edu andrew
cs.cmu.edu cs
ece.cmu.edu ece
dest: /etc/openafs/CellAlias
when: openafs.cell == "andrew.cmu.edu"
#####################################
- name: add/configure Coda client
when: coda.enabled | bool
tags: config
block:
- name: fetch Coda repository signing key
ansible.builtin.get_url:
url: http://coda.cs.cmu.edu/coda/jaharkes.key
dest: /etc/apt/keyrings/coda.asc
checksum: "sha256:045cba6000a9c9e86a52e68e6717c9a6d2ca03bd20d240b6b4393c37d03b55c8"
- name: add repo for Coda packages
ansible.builtin.apt_repository:
repo: "deb [signed-by=/etc/apt/keyrings/coda.asc] http://coda.cs.cmu.edu/coda bookworm main"
- name: install Coda
ansible.builtin.apt:
pkg: coda-client
- name: configure Coda
ansible.builtin.lineinfile:
path: /etc/coda/venus.conf
regexp: '^#?{{ item.key }}=.*$'
line: '{{ item.key }}={{ item.val }}'
loop:
- { key: "realm", val: '"{{ coda.realm }}"' }
- { key: "cachesize", val: '500M' }
- { key: "wholefilemaxsize", val: '200M' }
- { key: "wholefileminsize", val: '200M' }
#####################################
- name: configure Samba
tags: config
block:
- name: add repo for custom-built Samba packages
ansible.builtin.apt_repository:
repo: "deb [allow-insecure=yes trusted=yes] {{ samba_rebuild.root }} ./"
- name: install custom-built Samba packages
ansible.builtin.apt:
pkg: samba
state: latest
- name: configure Samba | set workgroup name
ansible.builtin.lineinfile:
path: /etc/samba/smb.conf
regexp: '^.*workgroup = .*$'
line: " workgroup = {{ samba.workgroup }}"
insertafter: '^\[global\]$'
- name: configure Samba | add user and preexec scripts
ansible.builtin.blockinfile:
path: /etc/samba/smb.conf
block: |
client use kerberos = off
add user script = /usr/sbin/useradd -s /usr/sbin/nologin -m '%u'
preexec = /usr/bin/aklog -c {{ openafs.cell }}
preexec close = no
insertbefore: '^#=+ Share Definitions =+$'
- name: configure Samba | Don't expose home directories
ansible.builtin.lineinfile:
path: /etc/samba/smb.conf
insertafter: '^\[homes\]$'
line: ' available = no'
- name: configure Samba | Make default shares not browseable
ansible.builtin.replace:
path: /etc/samba/smb.conf
regexp: '^([ \t]*)browseable = yes$'
replace: '\1browseable = no'
- name: configure Samba | add AFS share
ansible.builtin.blockinfile:
marker: "# {mark} OPENAFS SHARE"
block: |
[afs]
comment = AFS Root Directory Share
path = /afs
afs share = yes
vfs objects = fake_perms offline
store dos attributes = no
map archive = no
map hidden = no
map readonly = permissions
map system = no
browseable = yes
read only = no
guest ok = yes
path: /etc/samba/smb.conf
- name: configure Samba | add Coda share
when: coda.enabled | bool
ansible.builtin.blockinfile:
marker: "# {mark} CODA SHARE"
block: |
[coda]
comment = Coda Root Directory Share
path = /coda
vfs objects = fake_perms offline
store dos attributes = no
map archive = no
map hidden = no
map readonly = permissions
map system = no
browseable = yes
read only = no
guest ok = yes
path: /etc/samba/smb.conf
#####################################
- name: configure WebAuth application
tags: config
block:
- name: copy webauth source to /app
ansible.builtin.copy:
src: webauth/
dest: /app/
- name: create systemd file for webauth
ansible.builtin.copy:
content: |
[Unit]
Description=Web-based authentication application
After=network.target
[Service]
User=root
WorkingDirectory=/app
ExecStart=/usr/bin/gunicorn -w 4 webauth:app
Restart=always
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/webauth.service
- name: enable webauth service
command:
cmd: /bin/systemctl enable webauth.service
creates: /etc/systemd/system/multi-user.target.wants/webauth.service
- name: configure Caddy frontend for https offload
ansible.builtin.copy:
content: |
{{ hostname }}.local {
encode gzip
handle /static/* {
root * /app
file_server
}
handle {
reverse_proxy localhost:8000
}
}
dest: /etc/caddy/Caddyfile
#####################################
- name: cleanup
tags: config
block:
- name: clean apt package cache
command:
cmd: /usr/bin/apt-get clean