From 60bf7df899a8d52a1112958980d6f3d35fbaa824 Mon Sep 17 00:00:00 2001 From: Haletran Date: Mon, 2 Mar 2026 15:31:24 +0100 Subject: [PATCH] feat: duckdns finally working --- ansible/playbooks/install.yml | 5 +++++ ansible/playbooks/start-chatons.yml | 22 +++++++++++++++++++ ansible/playbooks/tasks/restart.yml | 29 +++++++++++++++++++++++++ ansible/playbooks/tasks/start.yml | 29 +++++++++++++++++++++++++ core/caddy/compose.yml | 4 ++-- core/caddy/config/Caddyfile | 2 ++ core/caddy/config/sites/diagrams.caddy | 2 +- core/caddy/config/sites/keycloak.caddy | 2 +- core/caddy/config/sites/outils.caddy | 2 +- core/caddy/config/sites/unbound.caddy | 2 +- core/caddy/config/sites/vogsphere.caddy | 2 +- core/duckdns/compose.yml | 11 ++++++++++ core/tools/caddy-init.sh | 2 +- core/tools/test-caddy | 10 ++++----- startup | 18 ++++++++++----- 15 files changed, 124 insertions(+), 18 deletions(-) create mode 100644 ansible/playbooks/start-chatons.yml create mode 100644 ansible/playbooks/tasks/restart.yml create mode 100644 ansible/playbooks/tasks/start.yml create mode 100644 core/duckdns/compose.yml diff --git a/ansible/playbooks/install.yml b/ansible/playbooks/install.yml index 824f097..8561aef 100644 --- a/ansible/playbooks/install.yml +++ b/ansible/playbooks/install.yml @@ -17,6 +17,8 @@ name: - htop - vim + - just + - unzip state: present - name: Include Docker installation tasks @@ -24,3 +26,6 @@ - name: Copy the project to the VM include_tasks: tasks/copy-to-vm.yml + + - name: Start all services + include_tasks: tasks/start.yml diff --git a/ansible/playbooks/start-chatons.yml b/ansible/playbooks/start-chatons.yml new file mode 100644 index 0000000..ffeedfd --- /dev/null +++ b/ansible/playbooks/start-chatons.yml @@ -0,0 +1,22 @@ +--- +- name: Configure ft_chatons base VM + hosts: ft_chatons + become: yes + tasks: + - name: Delete old project + file: + path: "/home/{{ ansible_user }}/projects/ft_chatons" + state: absent + + - name: Copy the project to the VM + include_tasks: tasks/copy-to-vm.yml + + - name: Ensure project directory exists + file: + path: "/home/{{ ansible_user }}/projects/ft_chatons" + state: directory + mode: '0755' + become: no + + - name: Re all services + include_tasks: tasks/restart.yml \ No newline at end of file diff --git a/ansible/playbooks/tasks/restart.yml b/ansible/playbooks/tasks/restart.yml new file mode 100644 index 0000000..fe0eab8 --- /dev/null +++ b/ansible/playbooks/tasks/restart.yml @@ -0,0 +1,29 @@ +- name: re duckdns + command: just re duckdns + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: re caddy + command: just re caddy + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: re doh + command: just re doh + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: re postgresql + command: just re postgresql + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: re keycloak + command: just re keycloak + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: re git + command: just re git + args: + chdir: /home/bapasqui/projects/ft_chatons \ No newline at end of file diff --git a/ansible/playbooks/tasks/start.yml b/ansible/playbooks/tasks/start.yml new file mode 100644 index 0000000..ddcf3d5 --- /dev/null +++ b/ansible/playbooks/tasks/start.yml @@ -0,0 +1,29 @@ +- name: Start duckdns + command: just start duckdns + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: Start caddy + command: just start caddy + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: Start doh + command: just start doh + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: Start postgresql + command: just start postgresql + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: Start keycloak + command: just start keycloak + args: + chdir: /home/bapasqui/projects/ft_chatons + +- name: Start git + command: just start git + args: + chdir: /home/bapasqui/projects/ft_chatons \ No newline at end of file diff --git a/core/caddy/compose.yml b/core/caddy/compose.yml index a612296..4ff373a 100644 --- a/core/caddy/compose.yml +++ b/core/caddy/compose.yml @@ -3,8 +3,8 @@ services: container_name: caddy image: library/caddy ports: - - "8081:80" - #- "443:443" + - "80:80" + - "443:443" volumes: - caddy-caddyfiles:/etc/caddy - caddy-data:/data diff --git a/core/caddy/config/Caddyfile b/core/caddy/config/Caddyfile index 49d2dd4..2435e96 100644 --- a/core/caddy/config/Caddyfile +++ b/core/caddy/config/Caddyfile @@ -1,4 +1,6 @@ { local_certs + default_bind 0.0.0.0 } + import sites/*.caddy diff --git a/core/caddy/config/sites/diagrams.caddy b/core/caddy/config/sites/diagrams.caddy index 32cbb68..5de4bcb 100644 --- a/core/caddy/config/sites/diagrams.caddy +++ b/core/caddy/config/sites/diagrams.caddy @@ -1,4 +1,4 @@ -http://diagrams.ft-chatons.local { +diagrams.chatons.duckdns.org { root * /srv/diagrams file_server } \ No newline at end of file diff --git a/core/caddy/config/sites/keycloak.caddy b/core/caddy/config/sites/keycloak.caddy index 7ab2f88..e7afa81 100644 --- a/core/caddy/config/sites/keycloak.caddy +++ b/core/caddy/config/sites/keycloak.caddy @@ -1,3 +1,3 @@ -http://keycloak.ft-chatons.local { +keycloak.chatons.duckdns.org { reverse_proxy keycloak:8080 } \ No newline at end of file diff --git a/core/caddy/config/sites/outils.caddy b/core/caddy/config/sites/outils.caddy index 5d1e588..6b64372 100644 --- a/core/caddy/config/sites/outils.caddy +++ b/core/caddy/config/sites/outils.caddy @@ -1,4 +1,4 @@ -http://outils.ft-chatons.local { +outils.chatons.duckdns.org { header X-Chatons "miaou" respond /healthcheck "OK" diff --git a/core/caddy/config/sites/unbound.caddy b/core/caddy/config/sites/unbound.caddy index c9bc80f..b8e0c63 100644 --- a/core/caddy/config/sites/unbound.caddy +++ b/core/caddy/config/sites/unbound.caddy @@ -1,4 +1,4 @@ -http://doh.ft-chatons.local { +http://doh.chatons.duckdns.org { tls internal diff --git a/core/caddy/config/sites/vogsphere.caddy b/core/caddy/config/sites/vogsphere.caddy index b52948c..16b57f5 100644 --- a/core/caddy/config/sites/vogsphere.caddy +++ b/core/caddy/config/sites/vogsphere.caddy @@ -1,3 +1,3 @@ -http://vogsphere.ft-chatons.local { +vogsphere.chatons.duckdns.org { reverse_proxy gitea:3000 } \ No newline at end of file diff --git a/core/duckdns/compose.yml b/core/duckdns/compose.yml new file mode 100644 index 0000000..b0e2445 --- /dev/null +++ b/core/duckdns/compose.yml @@ -0,0 +1,11 @@ +services: + duckdns: + image: linuxserver/duckdns:latest + container_name: duckdns + environment: + PUID: "1000" + PGID: "1000" + TZ: "Europe/Paris" + SUBDOMAINS: "chatons" + TOKEN: "7b3c8e72-17b9-4b80-a81b-628d1e74127e" + restart: always diff --git a/core/tools/caddy-init.sh b/core/tools/caddy-init.sh index 8ec516a..15bf018 100644 --- a/core/tools/caddy-init.sh +++ b/core/tools/caddy-init.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env +#!/usr/bin/env bash DRAWIO_VERSION="29.5.2" diff --git a/core/tools/test-caddy b/core/tools/test-caddy index 87e089c..bc5dd89 100755 --- a/core/tools/test-caddy +++ b/core/tools/test-caddy @@ -1,7 +1,7 @@ #!/usr/bin/env bash -DOMAIN_NAME="http://outils.ft-chatons.local:8080" -DIAGRAM_DOMAIN_NAME="http://diagrams.ft-chatons.local:8080" +DOMAIN_NAME="https://outils.chatons.duckdns.org" +DIAGRAM_DOMAIN_NAME="https://diagrams.chatons.duckdns.org" GREEN='\033[0;32m' RED='\033[0;31m' @@ -23,9 +23,9 @@ test_endpoint() { local tmp tmp=$(mktemp) - local curl_args=(-s -o "$tmp" -w "%{http_code}" "$url") + local curl_args=(-s -k -o "$tmp" -w "%{http_code}" "$url") if [ "$follow_redirects" = "true" ]; then - curl_args=(-s -L -o "$tmp" -w "%{http_code}" "$url") + curl_args=(-s -k -L -o "$tmp" -w "%{http_code}" "$url") fi local code @@ -75,7 +75,7 @@ test_endpoint_auth() { local tmp tmp=$(mktemp) - local curl_args=(-s -o "$tmp" -w "%{http_code}" -u "$username:$password" "$url") + local curl_args=(-s -k -o "$tmp" -w "%{http_code}" -u "$username:$password" "$url") local code code=$(curl "${curl_args[@]}" 2>/dev/null || echo "000") diff --git a/startup b/startup index f394ee0..e0e844d 100755 --- a/startup +++ b/startup @@ -1,30 +1,36 @@ -#!/usr/bin/env +#!/usr/bin/env bash case "$1" in vm) qemu-system-x86_64 \ -enable-kvm -cpu host -smp 4 -m 4G \ -device e1000,netdev=net0 \ - -netdev user,id=net0,hostfwd=tcp::2222-:22 \ + -netdev user,id=net0,hostfwd=tcp::2222-:22,hostfwd=tcp::80-:80,hostfwd=tcp::443-:443 \ -drive if=pflash,format=raw,readonly=on,file=/usr/share/OVMF/OVMF_CODE.fd \ -hda ft_chatons.qcow2 ;; - command) + vm-command) ansible -i ansible/inventory ft_chatons -a "$2" ;; - setup) + vm-setup) ansible-playbook -i ansible/inventory ansible/playbooks/install.yml -K ;; + vm-re) + ansible-playbook -i ansible/inventory ansible/playbooks/start-chatons.yml -K + ;; connect) ssh -p 2222 bapasqui@localhost ;; start) + just start duckdns just start caddy just start doh just start postgresql just start keycloak + just start git ;; down) + just down duckdns just down caddy just down doh just down postgresql @@ -32,6 +38,7 @@ case "$1" in just down git ;; clean) + just clean duckdns just clean caddy just clean doh just clean postgresql @@ -39,10 +46,11 @@ case "$1" in just clean git ;; restart) + just re duckdns just re caddy just re doh just re postgresql just re git - #just re keycloak + just re keycloak ;; esac \ No newline at end of file