-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathprovision.yml
254 lines (199 loc) · 8.26 KB
/
provision.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
---
- hosts: all
become: true
become_method: doas
vars:
ansible_python_interpreter: /usr/local/bin/python3
tasks:
- name: load settings
include_vars: "settings.yml"
- name: set install url
command: echo "{{openbsd_mirror}}/{{openbsd_mirror_directory}}" > /etc/installurl
- name: packages
openbsd_pkg: name="{{packages}}" state='present'
- name: install prometheus node_exporter
become: yes
command: go get github.com/prometheus/node_exporter
args:
creates: /usr/bin/node_exporter
environment:
GOPATH: /usr
- name: add node_exporter user
user:
name: _node-exporter
shell: /sbin/nologin
home: /nonexistent
create_home: false
- name: copy prometheus node_exporter rc script
copy: src='nodeexporter' dest='/etc/rc.d/' owner='root' group='wheel' mode='a+x'
# TODO INSTALL wireguard here
- name: copy wireguard rc script
copy: src='wireguard' dest='/etc/rc.d/' owner='root' group='wheel' mode='a+x'
- name: wireguard conf directory
file: path='/etc/wireguard' state='directory' owner='root' group='wheel' mode='0640'
- name: generate wireguard private key
shell: "umask 077; wg genkey > /etc/wireguard/privatekey"
args:
creates: "/etc/wireguard/privatekey"
- name: register wireguard private key
command: "cat /etc/wireguard/privatekey"
register: wireguard_private_key_cmd
changed_when: false
- name: compute wireguard public key
shell: "wg pubkey < /etc/wireguard/publickey"
register: "wireguard_public_key_cmd"
changed_when: false
- name: wireguard conf
template:
src: "tun0.conf.j2"
dest: "/etc/wireguard/tun0.conf"
owner: root
group: wheel
mode: 0640
- name: update root user full name
command: usermod -c "{{full_name}}" root
- name: zshell and groups ({{user}})
user: name='{{user}}' state='present' groups='wheel' shell='/usr/local/bin/zsh'
- name: zshell (root)
user: name='root' state='present' shell='/usr/local/bin/zsh'
# Doesn't appear to affect matters
#- name: korn shell vi mode
#lineinfile: dest='/etc/ksh.kshrc' regexp='^(.*)emacs(.*)$' line='\1vi\2' backrefs=yes
- name: default editor ({{user}})
become_user: "{{user}}"
blockinfile:
dest: "/home/{{user}}/.zshrc"
create: 'yes'
block: |
alias vi=vim
EDITOR=vi
VISUAL=$EDITOR
export EDITOR VISUAL
- name: default editor (root)
blockinfile:
dest: "/root/.zshrc"
create: 'yes'
block: |
alias vi=vim
EDITOR=vi
VISUAL=$EDITOR
export EDITOR VISUAL
- name: ntp servers
template: src='ntpd.conf.j2' dest='/etc/ntpd.conf' owner='root' group='wheel' mode='0644'
- name: set date from remote
command: rdate -nv {{ntp_pool}}
- name: clone dotfiles ({{user}})
become_user: "{{user}}"
git:
repo: "{{dotfiles_repo}}"
dest: "/home/{{user}}/.dotfiles"
recursive: no
accept_hostkey: yes
depth: 1
- name: link dotfiles into home folder
become_user: "{{user}}"
file:
src: "{{item.src}}"
dest: "{{item.dst}}"
state: link
with_items: "{{dotfiles_links}}"
- name: mail secrets file
lineinfile: dest='/etc/mail/secrets' line='googlemail {{gmail_user}}:{{gmail_pass}}' create='yes' owner='root' group='_smtpd' mode='0640'
- name: mail secrets db
command: makemap /etc/mail/secrets
- name: relay all mail through google mail (opensmtpd)
blockinfile:
dest: /etc/mail/smtpd.conf
block: |
table secrets db:/etc/mail/secrets.db
action "relay" relay host tls+auth://googlemail@smtp.googlemail.com:587 auth <secrets>
match for any action "relay"
- name: forward root mail to personal account
lineinfile: dest='/etc/mail/aliases' regexp='^(#\ +)?root:' line='root{{\':\'}} {{email}}'
- name: update aliases
command: newaliases
- name: set noatime and softdep on root partition
lineinfile: dest='/etc/fstab' backrefs='yes' regexp='^([0-9a-f]{16}\.[a-z]{1})\ / ' line='\1 / ffs rw,noatime,softdep 1 1'
- name: dns resolvers
template: src='resolv.conf.j2' dest='/etc/resolv.conf' owner='root' group='wheel' mode='0644'
- name: recursive caching dns server (unbound)
template:
src: 'unbound.conf.j2'
dest: '/var/unbound/etc/unbound.conf'
owner: 'root'
group: 'wheel'
mode: '0644'
- name: copy unbound rc script
copy: src='unbound' dest='/etc/rc.d/' owner='root' group='wheel' mode='a+x'
- name: copy unbound conf
copy: remote_src=true src=/var/unbound/etc/unbound.conf dest=/etc/unbound.conf
- name: adservers mkdb script
copy: src='adservers_mkdb.sh' dest='/usr/local/bin/adservers_mkdb' owner='root' group='wheel' mode='a+x'
- name: create permitted adservers db
template: src='adservers_permitted.db.j2' dest='/etc/adservers_permitted.db' owner='root' group='wheel' mode='0640'
- name: create adservers db
command: /usr/local/bin/adservers_mkdb
ignore_errors: yes
args:
creates: /etc/adservers.db
- name: cron to update adservers db
cron:
name: 'update adservers db'
special_time: monthly
job: '/usr/local/bin/adservers_mkdb'
- name: network bridge
copy: src='hostname.bridge0' dest='/etc/hostname.bridge0' owner='root' group='wheel' mode='0640'
- name: virtual ethernet interface
template: src='hostname.vether0.j2' dest='/etc/hostname.vether0' owner='root' group='wheel' mode='0640'
- name: physical ethernet interfaces
copy: src='hostname.emx' dest="/etc/hostname.{{item}}" owner="root" group="wheel" mode="0640"
with_items:
- 'em0'
- 'em1'
- 'em2'
- name: ppp over ethernet
template: src='hostname.pppoe0.j2' dest='/etc/hostname.pppoe0' owner='root' group='wheel' mode='0640'
- name: wireless access point
template: src='hostname.athn0.j2' dest='/etc/hostname.athn0' owner='root' group='wheel' mode='0640'
- name: wireguard tunnel
template: src='hostname.tun0.j2' dest='/etc/hostname.tun0' owner='root' group='wheel' mode='0640'
- name: dhcpd
template: src='dhcpd.conf.j2' dest='/etc/dhcpd.conf' owner='root' group='wheel' mode='0640'
- name: sensorsd
copy: src='sensorsd.conf' dest='/etc/sensorsd.conf' owner='root' group='wheel' mode='0600'
- name: bogon mkdb script
copy: src='bogons_mkdb.sh' dest='/usr/local/bin/bogons_mkdb' owner='root' group='wheel' mode='a+x'
- name: create bogons db
command: /usr/local/bin/bogons_mkdb
args:
creates: /etc/bogons.db
- name: cron to update bogons db
cron:
name: 'update bogons db'
special_time: weekly
job: '/usr/local/bin/bogons_mkdb'
- name: packet filter (pf)
template: src='pf.conf.j2' dest='/etc/pf.conf' owner='root' group='wheel' mode='0600' validate='pfctl -nf %s'
- name: syslog conf for pf
lineinfile: dest='/etc/syslog.conf' line='local0.info /var/log/pflog.txt'
- name: pf log rotator
copy: src='pf_log_rotate.sh' dest='/usr/local/bin/pf_log_rotate' owner='root' group='wheel' mode='a+x'
- name: cron to rotate pf logs
cron:
name: 'rotate packet filter logs'
special_time: hourly
job: '/usr/local/bin/pf_log_rotate'
- name: pf log file
file: path='/var/log/pflog.txt' owner='root' group='wheel' mode='0600' state='touch'
- name: kernel configuration (sysctl)
copy: src='sysctl.conf' dest='/etc/sysctl.conf' owner='root' group='wheel' mode='0600'
- name: enable services
lineinfile: dest='/etc/rc.conf.local' regexp='^{{item.name}}_flags=' line='{{item.name}}_flags=\"{{item.flags}}\"' create='yes'
with_items:
- { name: 'unbound', flags: '' }
- { name: 'ntpd', flags: '-s' }
- { name: 'dhcpd', flags: 'vether0' }
- { name: 'sensorsd', flags: '' }
- { name: 'sndiod', flags: 'NO' }
- { name: 'nodeexporter', flags: '--web.listen-address={{network_address}}:9100' }
- { name: 'wireguard', flags: 'tun0' }