blob: 2de99efa678da15a0892cda884c0d0102220b276 (
plain) (
blame)
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
|
---
## TODO: add storage handling!
- set_fact:
whawty_auth_instance_basepath: "/srv/whawty/{{ whawty_auth_instance }}"
##
## TODO: custom user
- name: create instance directories
loop:
- config
- store
file:
path: "{{ whawty_auth_instance_basepath }}/{{ item }}"
state: directory
- name: generate store config
template:
src: store.yml.j2
dest: "{{ whawty_auth_instance_basepath }}/config/store.yml"
mode: 0400
- name: set up tls config
when: "'tls' in whawty_auth_instances[whawty_auth_instance]"
block:
- name: create tls directory
file:
path: "{{ whawty_auth_instance_basepath }}/config/tls"
state: directory
mode: 0400
- name: generate/install/fetch TLS certificate
vars:
x509_certificate_name: "whawty-auth-{{ whawty_auth_instance }}"
x509_certificate_hostnames: "{{ whawty_auth_instances[whawty_auth_instance].hostnames }}"
x509_certificate_renewal:
install:
- dest: "{{ whawty_auth_instance_basepath }}/config/tls/cert.pem"
src:
- fullchain
mode: "0400"
- dest: "{{ whawty_auth_instance_basepath }}/config/tls/key.pem"
src:
- key
mode: "0400"
reload: |
pod_id=$(crictl pods -q --state ready --name "^whawty-auth-{{ whawty_auth_instance }}-{{ ansible_nodename }}$")
[ -n "$pod_id" ] || exit 0
container_id=$(crictl ps -q --name '^app$' -p "$pod_id")
[ -n "$container_id" ] || exit 0
crictl stop "$container_id"
include_role:
name: "x509/{{ whawty_auth_instances[whawty_auth_instance].tls.certificate_provider }}/cert"
- name: generate store config
template:
src: web.yml.j2
dest: "{{ whawty_auth_instance_basepath }}/config/web.yml"
mode: 0400
- name: set up sync config
when: "'sync' in whawty_auth_instances[whawty_auth_instance]"
block:
- name: create sync directory
file:
path: "{{ whawty_auth_instance_basepath }}/sync/gokr-rsyncd"
state: directory
- name: generate sync config
template:
src: sync.toml.j2
dest: "{{ whawty_auth_instance_basepath }}/sync/config.toml"
- name: generate authorized_keys for sync
copy:
content: "{{ whawty_auth_instances[whawty_auth_instance].sync.authorized_keys | join('\n') }}\n"
dest: "{{ whawty_auth_instance_basepath }}/sync/authorized_keys"
- name: generate ssh host key for sync
command: "ssh-keygen -q -t ed25519 -f '{{ whawty_auth_instance_basepath }}/sync/gokr-rsyncd/ssh_host_ed25519_key' -C '' -N ''"
args:
creates: "{{ whawty_auth_instance_basepath }}/sync/gokr-rsyncd/ssh_host_ed25519_key"
- name: install pod manifest
vars:
whawty_auth_instance_config_hash_items__yaml: |
- path: "{{ whawty_auth_instance_basepath }}/config/store.yml"
{% if 'tls' in whawty_auth_instances[whawty_auth_instance] %}
- path: "{{ whawty_auth_instance_basepath }}/config/web.yml"
{% endif %}
{% if 'sync' in whawty_auth_instances[whawty_auth_instance] %}
- path: "{{ whawty_auth_instance_basepath }}/sync/config.toml"
- path: "{{ whawty_auth_instance_basepath }}/sync/authorized_keys"
- path: "{{ whawty_auth_instance_basepath }}/sync/gokr-rsyncd/ssh_host_ed25519_key"
{% endif %}
kubernetes_standalone_pod:
name: "whawty-auth-{{ whawty_auth_instance }}"
spec: "{{ lookup('template', 'pod-spec.yml.j2') }}"
config_hash_items: "{{ whawty_auth_instance_config_hash_items__yaml | from_yaml }}"
include_role:
name: kubernetes/standalone/pod
|