Skip to content

Commit 2460897

Browse files
authored
feat: test auto-dns on the auth endpoint (#49)
* feat: test auto-dns on the auth endpoint * test: debug affected roles scripts * test: changed role feature * feat: add sanity test for affected roles * fix: issue with playbook_dir being absolute path * fix: caddy file comment should use # * feat: test dynamicdns * chore: remove test with dns challenge * feat: activate dynamic_domains * fix: dynamic dns misconfiguration
1 parent 21e94fc commit 2460897

File tree

6 files changed

+33
-19
lines changed

6 files changed

+33
-19
lines changed

.github/workflows/ansible.yml

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828

2929
# Steps represent a sequence of tasks that will be executed as part of the job
3030
steps:
31-
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
3231
- uses: actions/checkout@v4
3332

3433
- name: Run ansible-lint

ansible/affected-roles.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
- name: Determine affected roles
2+
hosts: localhost
3+
gather_facts: false
4+
5+
roles:
6+
- utils-affected-roles

ansible/roles/docker-swarm-app-caddy/assets/Caddyfile

+18-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
order authenticate before respond
77
order authorize before basicauth
88

9+
dynamic_dns {
10+
provider digitalocean {env.DIGITALOCEAN_API_TOKEN}
11+
domains {
12+
{{domain}} @ www
13+
}
14+
dynamic_domains
15+
}
16+
917
security {
1018
oauth identity provider github {env.GITHUB_CLIENT_ID} {env.GITHUB_CLIENT_SECRET}
1119

@@ -49,12 +57,17 @@
4957
}
5058
}
5159

60+
# Snippet enable automatic DNS configuration
61+
(external-dns) {
62+
tls {
63+
dns digitalocean {env.DIGITALOCEAN_API_TOKEN}
64+
}
65+
}
66+
67+
# Auth endpoint for caddy security
5268
auth.{{domain}} {
69+
import external-dns
5370
authenticate with myportal
5471
}
5572

56-
(external_dns) {
57-
tls {
58-
dns digitalocean {env.DIGITALOCEAN_API_TOKEN}
59-
}
60-
}
73+

ansible/roles/docker-swarm-app-caddy/assets/caddy-stack.yml

-12
Original file line numberDiff line numberDiff line change
@@ -54,18 +54,6 @@ services:
5454
caddy.reverse_proxy: "{{ '{{' }}upstreams 80{{ '}}' }}"
5555
caddy.authorize: with admins_policy
5656

57-
whoami-dns:
58-
# A container that exposes an API to show its IP address
59-
image: containous/whoami
60-
networks:
61-
- caddy
62-
deploy:
63-
labels:
64-
caddy: whoami-dns.{{domain}}
65-
caddy.import: external_dns
66-
caddy.reverse_proxy: "{{ '{{' }}upstreams 80{{ '}}' }}"
67-
68-
6957
volumes:
7058
caddy_data:
7159
caddy_config:
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Default variables for affected_roles role
22
default_branch: "main"
3-
roles_folder: "{{ playbook_dir }}/roles"
3+
roles_folder: "ansible/roles"

ansible/roles/utils-affected-roles/tasks/main.yaml

+8
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
tags:
2222
- skip_ansible_lint
2323

24+
- name: Debug git diff output
25+
debug:
26+
msg: "{{ diff.stdout_lines }}"
27+
2428
- name: Extract folders from the diff
2529
set_fact:
2630
changed_folders: "{{
@@ -30,6 +34,10 @@
3034
}}"
3135
when: branch.stdout != default_branch
3236

37+
- name: Debug changed_folders output
38+
debug:
39+
msg: "{{ changed_folders }}"
40+
3341
- name: Filter folders within the roles directory
3442
set_fact:
3543
roles_with_changes: "{{ changed_folders

0 commit comments

Comments
 (0)