Skip to content

Commit 862c70b

Browse files
committed
many fixes
1 parent 96c2293 commit 862c70b

37 files changed

Lines changed: 1189 additions & 808 deletions

ansible/roles/idp_zitadel/defaults/main.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ terrarium_zitadel_enabled: "{{ terrarium_idp_mode == 'local' }}"
22
terrarium_zitadel_dir: "{{ terrarium_state_dir }}/zitadel"
33
terrarium_zitadel_postgres_dir: "{{ terrarium_zitadel_dir }}/postgres"
44
terrarium_zitadel_bootstrap_dir: "{{ terrarium_zitadel_dir }}/bootstrap"
5-
terrarium_zitadel_tf_dir: "{{ terrarium_zitadel_dir }}/terraform"
65
terrarium_zitadel_outputs_path: /etc/terrarium/zitadel-apps.json
76
terrarium_zitadel_api_port: 8082
87
terrarium_zitadel_login_port: 8083
98
terrarium_zitadel_version: v4.13.0
109
terrarium_zitadel_postgres_image: postgres:17.2-alpine
11-
terrarium_zitadel_tofu_image: ghcr.io/opentofu/opentofu:1.10.6
12-
terrarium_zitadel_provider_version: 2.12.3
1310
terrarium_zitadel_pat_expiration: "2099-01-01T00:00:00Z"
1411
terrarium_zitadel_project_name: Terrarium

ansible/roles/idp_zitadel/tasks/main.yml

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
- "{{ terrarium_zitadel_dir }}"
3636
- "{{ terrarium_zitadel_postgres_dir }}"
3737
- "{{ terrarium_zitadel_bootstrap_dir }}"
38-
- "{{ terrarium_zitadel_tf_dir }}"
3938

4039
- name: Generate ZITADEL master key
4140
ansible.builtin.shell: "umask 077 && tr -dc 'A-Za-z0-9' </dev/urandom | head -c 32 > /etc/terrarium/secrets/zitadel_masterkey"
@@ -81,19 +80,6 @@
8180
terrarium_zitadel_admin_password: "{{ terrarium_zitadel_admin_password_raw.stdout }}"
8281
notify: restart terrarium zitadel
8382

84-
- name: Render ZITADEL Terraform config
85-
ansible.builtin.template:
86-
src: terraform-main.tf.j2
87-
dest: "{{ terrarium_zitadel_tf_dir }}/main.tf"
88-
mode: "0600"
89-
notify: restart terrarium zitadel
90-
91-
- name: Render ZITADEL Terraform outputs
92-
ansible.builtin.template:
93-
src: terraform-outputs.tf.j2
94-
dest: "{{ terrarium_zitadel_tf_dir }}/outputs.tf"
95-
mode: "0600"
96-
9783
- name: Render ZITADEL systemd unit
9884
ansible.builtin.template:
9985
src: terrarium-zitadel.service.j2

ansible/roles/idp_zitadel/templates/terraform-main.tf.j2

Lines changed: 0 additions & 102 deletions
This file was deleted.

ansible/roles/idp_zitadel/templates/terraform-outputs.tf.j2

Lines changed: 0 additions & 32 deletions
This file was deleted.

ansible/roles/lxd/tasks/main.yml

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -170,18 +170,12 @@
170170
interface_in: lxdbr0
171171
interface_out: "{{ ansible_default_ipv4.interface }}"
172172

173-
- name: Configure ACME email when custom domain is used
174-
ansible.builtin.command: "/snap/bin/lxc config set acme.email {{ terrarium_acme_email }}"
175-
when:
176-
- terrarium_acme_email | length > 0
177-
- not terrarium_lxd_domain.endswith('.traefik.me')
178-
changed_when: false
179-
180-
- name: Configure ACME domain when custom domain is used
181-
ansible.builtin.command: "/snap/bin/lxc config set acme.domain {{ terrarium_lxd_domain }}"
182-
when:
183-
- terrarium_acme_email | length > 0
184-
- not terrarium_lxd_domain.endswith('.traefik.me')
173+
- name: Disable LXD ACME certificate management
174+
ansible.builtin.command: "/snap/bin/lxc config unset {{ item }}"
175+
loop:
176+
- acme.email
177+
- acme.domain
178+
failed_when: false
185179
changed_when: false
186180

187181
- name: Configure OIDC issuer when provided

ansible/roles/oauth2_proxy/templates/docker-compose.yml.j2

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ services:
66
restart: unless-stopped
77
{% if terrarium_idp_mode == 'local' %}
88
environment:
9-
SSL_CERT_FILE: /etc/ssl/certs/terrarium-bootstrap.crt
9+
SSL_CERT_FILE: /etc/ssl/certs/terrarium-ca-certificates.crt
1010
{% endif %}
1111
command:
1212
- --config=/etc/oauth2-proxy/oauth2-proxy.cfg
1313
volumes:
1414
- "{{ terrarium_oauth2_proxy_dir }}/oauth2-proxy.cfg:/etc/oauth2-proxy/oauth2-proxy.cfg:ro"
1515
{% if terrarium_idp_mode == 'local' %}
16-
- "{{ terrarium_traefik_config_dir }}/bootstrap-certs/terrarium-bootstrap.crt:/etc/ssl/certs/terrarium-bootstrap.crt:ro"
16+
- "/etc/ssl/certs/ca-certificates.crt:/etc/ssl/certs/terrarium-ca-certificates.crt:ro"
1717
{% endif %}

ansible/roles/oauth2_proxy/templates/oauth2-proxy.cfg.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
provider = "oidc"
22
provider_display_name = "Terrarium"
3-
http_address = "0.0.0.0:{{ terrarium_oauth2_proxy_port }}"
3+
http_address = "127.0.0.1:{{ terrarium_oauth2_proxy_port }}"
44
redirect_url = "https://{{ terrarium_manage_domain }}/oauth2/callback"
55
oidc_issuer_url = "{{ terrarium_oauth2_proxy_oidc_issuer }}"
66
oidc_groups_claim = "groups"

ansible/roles/traefik/tasks/main.yml

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -45,51 +45,15 @@
4545
- "{{ terrarium_traefik_config_dir }}/bootstrap-certs"
4646
- /var/lib/traefik
4747

48-
- name: Derive bootstrap certificate root domain
48+
- name: Determine whether bootstrap TLS is required
4949
ansible.builtin.set_fact:
50-
terrarium_bootstrap_tls_root_domain: >-
51-
{{
52-
terrarium_root_domain
53-
if (terrarium_root_domain | default('') | length > 0)
54-
else (
55-
terrarium_manage_domain.split('.', 1)[1]
56-
if ('.' in terrarium_manage_domain)
57-
else ''
58-
)
59-
}}
50+
terrarium_bootstrap_tls_enabled: "{{ terrarium_idp_mode == 'local' and (terrarium_auth_domain | default('') | length > 0) }}"
6051

6152
- name: Build bootstrap certificate SAN list
6253
ansible.builtin.set_fact:
6354
terrarium_bootstrap_tls_domains: >-
6455
{{
65-
(
66-
[
67-
terrarium_manage_domain,
68-
terrarium_proxy_domain
69-
]
70-
+ (
71-
[terrarium_auth_domain]
72-
if (
73-
(terrarium_auth_domain | default('') | length > 0)
74-
and not (
75-
(terrarium_bootstrap_tls_root_domain | default('') | length > 0)
76-
and (
77-
terrarium_auth_domain == terrarium_bootstrap_tls_root_domain
78-
or terrarium_auth_domain.endswith('.' ~ terrarium_bootstrap_tls_root_domain)
79-
)
80-
)
81-
)
82-
else []
83-
)
84-
+ (
85-
['*.' ~ terrarium_bootstrap_tls_root_domain, terrarium_bootstrap_tls_root_domain]
86-
if (terrarium_bootstrap_tls_root_domain | default('') | length > 0)
87-
else []
88-
)
89-
)
90-
| reject('equalto', '')
91-
| unique
92-
| list
56+
[terrarium_auth_domain] if terrarium_bootstrap_tls_enabled else []
9357
}}
9458
9559
- name: Render Traefik bootstrap certificate OpenSSL config
@@ -98,11 +62,13 @@
9862
dest: "{{ terrarium_traefik_config_dir }}/bootstrap-certs/openssl.cnf"
9963
mode: "0644"
10064
register: terrarium_bootstrap_tls_openssl_config
65+
when: terrarium_bootstrap_tls_enabled
10166

10267
- name: Check whether Traefik bootstrap certificate exists
10368
ansible.builtin.stat:
10469
path: "{{ terrarium_traefik_config_dir }}/bootstrap-certs/terrarium-bootstrap.crt"
10570
register: terrarium_bootstrap_tls_cert_stat
71+
when: terrarium_bootstrap_tls_enabled
10672

10773
- name: Generate Traefik bootstrap certificate
10874
ansible.builtin.command:
@@ -122,6 +88,7 @@
12288
- -config
12389
- "{{ terrarium_traefik_config_dir }}/bootstrap-certs/openssl.cnf"
12490
when:
91+
- terrarium_bootstrap_tls_enabled
12592
- terrarium_bootstrap_tls_openssl_config.changed or not terrarium_bootstrap_tls_cert_stat.stat.exists
12693
notify: restart traefik
12794

@@ -131,6 +98,14 @@
13198
dest: "{{ terrarium_traefik_config_dir }}/dynamic/bootstrap-cert.yml"
13299
mode: "0644"
133100
notify: restart traefik
101+
when: terrarium_bootstrap_tls_enabled
102+
103+
- name: Remove Traefik bootstrap certificate config when bootstrap TLS is not required
104+
ansible.builtin.file:
105+
path: "{{ terrarium_traefik_config_dir }}/dynamic/bootstrap-cert.yml"
106+
state: absent
107+
notify: restart traefik
108+
when: not terrarium_bootstrap_tls_enabled
134109

135110
- name: Install Traefik bootstrap certificate into system trust store
136111
ansible.builtin.copy:
@@ -139,15 +114,20 @@
139114
mode: "0644"
140115
remote_src: true
141116
register: terrarium_bootstrap_tls_system_ca
117+
when: terrarium_bootstrap_tls_enabled
142118

143119
- name: Refresh system CA certificates for bootstrap trust
144120
ansible.builtin.command: update-ca-certificates
145-
when: terrarium_bootstrap_tls_system_ca.changed
121+
when:
122+
- terrarium_bootstrap_tls_enabled
123+
- terrarium_bootstrap_tls_system_ca.changed
146124
changed_when: terrarium_bootstrap_tls_system_ca.changed
147125

148126
- name: Restart LXD after bootstrap trust changes
149127
ansible.builtin.command: systemctl try-restart snap.lxd.daemon.service
150-
when: terrarium_bootstrap_tls_system_ca.changed
128+
when:
129+
- terrarium_bootstrap_tls_enabled
130+
- terrarium_bootstrap_tls_system_ca.changed
151131
changed_when: false
152132
failed_when: false
153133

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
tls:
2-
stores:
3-
default:
4-
defaultCertificate:
5-
certFile: {{ terrarium_traefik_config_dir }}/bootstrap-certs/terrarium-bootstrap.crt
6-
keyFile: {{ terrarium_traefik_config_dir }}/bootstrap-certs/terrarium-bootstrap.key
2+
certificates:
3+
- certFile: {{ terrarium_traefik_config_dir }}/bootstrap-certs/terrarium-bootstrap.crt
4+
keyFile: {{ terrarium_traefik_config_dir }}/bootstrap-certs/terrarium-bootstrap.key

ansible/roles/traefik/templates/terrarium-dynamic.yml.j2

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ http:
6767
service: api@internal
6868
tls:
6969
certResolver: letsencrypt
70+
lxd:
71+
entryPoints:
72+
- websecure
73+
rule: Host(`{{ terrarium_lxd_domain }}`)
74+
service: lxd
75+
tls:
76+
certResolver: letsencrypt
7077
{% if terrarium_idp_mode == 'local' %}
7178
zitadel-root-bootstrap:
7279
entryPoints:
@@ -142,6 +149,12 @@ http:
142149
loadBalancer:
143150
servers:
144151
- url: http://127.0.0.1:9090
152+
lxd:
153+
loadBalancer:
154+
serversTransport: lxd-loopback
155+
passHostHeader: true
156+
servers:
157+
- url: https://127.0.0.1:8443
145158
{% if terrarium_idp_mode == 'local' %}
146159
zitadel-login:
147160
loadBalancer:
@@ -152,18 +165,6 @@ http:
152165
servers:
153166
- url: h2c://127.0.0.1:8082
154167
{% endif %}
155-
156-
tcp:
157-
routers:
158-
lxd:
159-
entryPoints:
160-
- websecure
161-
rule: HostSNI(`{{ terrarium_lxd_domain }}`)
162-
service: lxd
163-
tls:
164-
passthrough: true
165-
services:
166-
lxd:
167-
loadBalancer:
168-
servers:
169-
- address: 127.0.0.1:8443
168+
serversTransports:
169+
lxd-loopback:
170+
insecureSkipVerify: true

0 commit comments

Comments
 (0)