Ensure proper directory configuration

This commit is contained in:
Fabio Sinibaldi 2026-09-15 15:54:28 +02:00
parent 3021b68b19
commit d591e1620e
2 changed files with 41 additions and 24 deletions

View File

@ -1,38 +1,52 @@
--- ---
- name: Ensure Pangolin directory exists - name: Ensure Pangolin directory exists
ansible.builtin.file: ansible.builtin.file:
path: /home/ubuntu/pangolin path: "/home/{{ ansible_user }}/compose_projects/pangolin"
state: directory state: directory
mode: '0755'
register: compose_dir
- name: Ensure Pangolin config directory exists - name: Ensure Pangolin config directory exists
ansible.builtin.file: ansible.builtin.file:
path: /home/ubuntu/pangolin/pangolin_config path: "{{ compose_dir.path }}/pangolin_config"
state: directory state: directory
mode: '0755'
register: pangolin_config
- name: Template Pangolin config file - name: Template Pangolin config file
ansible.builtin.template: ansible.builtin.template:
src: pangolin_config.yml.j2 src: pangolin_config.yml.j2
dest: /home/ubuntu/pangolin/pangolin_config/config.yaml dest: "{{ pangolin_config.path }}/config.yaml"
- name: Ensure Traefik config directory exists - name: Ensure Traefik config directory exists
ansible.builtin.file: ansible.builtin.file:
path: /home/ubuntu/pangolin/config/traefik path: "{{ pangolin_config.path }}/traefik"
mode: '0755'
state: directory state: directory
register: traefik_config
- name: Ensure gerbil config directory exists
ansible.builtin.file:
path: "{{ pangolin_config.path }}/gerbil"
mode: '0755'
state: directory
register: gerbil_config
- name: Template Traefik config file - name: Template Traefik config file
ansible.builtin.template: ansible.builtin.template:
src: traefik_config.yml.j2 src: traefik_config.yml.j2
dest: /home/ubuntu/pangolin/config/traefik/traefik_config.yml dest: "{{ traefik_config.path }}/traefik_config.yml"
- name: Template Traefik dynamic config file - name: Template Traefik dynamic config file
ansible.builtin.template: ansible.builtin.template:
src: dynamic_config.yml.j2 src: dynamic_config.yml.j2
dest: /home/ubuntu/pangolin/config/traefik/dynamic_config.yml dest: "{{ traefik_config.path }}/dynamic_config.yml"
- name: Template docker-compose.yml for Pangolin - name: Template docker-compose.yml for Pangolin
ansible.builtin.template: ansible.builtin.template:
src: docker-compose.yml.j2 src: docker-compose.yml.j2
dest: /home/ubuntu/pangolin/docker-compose.yml dest: "{{ compose_dir.path }}/docker-compose.yml"
register: pangolin_compose_template register: pangolin_compose_template
- name: Check if Pangolin container is running - name: Check if Pangolin container is running
@ -63,22 +77,25 @@
ignore_errors: true ignore_errors: true
- name: Start Pangolin and Gerbil with Docker Compose (force recreate if needed) - name: Start Pangolin and Gerbil with Docker Compose (force recreate if needed)
ansible.builtin.shell: | community.docker.docker_compose_v2:
cd /home/ubuntu/pangolin project_src: "{{ compose_dir.path }}"
docker compose up -d --force-recreate
when: pangolin_compose_needs_up
register: docker_compose_up
failed_when: docker_compose_up.rc != 0
- name: Check Docker Compose service status
ansible.builtin.shell: |
cd /home/ubuntu/pangolin
docker compose ps
register: docker_compose_status register: docker_compose_status
# ansible.builtin.shell: |
# cd /home/ubuntu/pangolin
# docker compose up -d --force-recreate
# when: pangolin_compose_needs_up
# register: docker_compose_up
# failed_when: docker_compose_up.rc != 0
# - name: Check Docker Compose service status
# ansible.builtin.shell: |
# cd /home/ubuntu/pangolin
# docker compose ps
# register: docker_compose_status
- name: Display Docker Compose service status - name: Display Docker Compose service status
ansible.builtin.debug: ansible.builtin.debug:
msg: "{{ docker_compose_status.stdout_lines }}" msg: "{{ docker_compose_status }}"
- name: "Assert that mandatory variables are defined and not default" - name: "Assert that mandatory variables are defined and not default"
ansible.builtin.assert: ansible.builtin.assert:

View File

@ -4,7 +4,7 @@ services:
container_name: pangolin container_name: pangolin
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./pangolin_config:/app/config - {{ pangolin_config.path }}:/app/config
healthcheck: healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/"] test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/"]
interval: "3s" interval: "3s"
@ -24,7 +24,7 @@ services:
- --remoteConfig=http://pangolin:3001/api/v1/gerbil/get-config - --remoteConfig=http://pangolin:3001/api/v1/gerbil/get-config
- --reportBandwidthTo=http://pangolin:3001/api/v1/gerbil/receive-bandwidth - --reportBandwidthTo=http://pangolin:3001/api/v1/gerbil/receive-bandwidth
volumes: volumes:
- ./gerbil_config/:/var/config - {{ gerbil_config.path }}:/var/config
cap_add: cap_add:
- NET_ADMIN - NET_ADMIN
- SYS_MODULE - SYS_MODULE
@ -44,9 +44,9 @@ services:
command: command:
- --configFile=/etc/traefik/traefik_config.yml - --configFile=/etc/traefik/traefik_config.yml
volumes: volumes:
- ./config/traefik:/etc/traefik:ro # Volume to store the Traefik configuration - {{ traefik_config.path }}:/etc/traefik:ro # Volume to store the Traefik configuration
- ./config/letsencrypt:/letsencrypt # Volume to store the Let's Encrypt certificates - {{ pangolin_config.path }}/letsencrypt:/letsencrypt # Volume to store the Let's Encrypt certificates
- ./config/traefik/logs:/var/log/traefik # Volume to store Traefik logs - {{ traefik_config.path }}/logs:/var/log/traefik # Volume to store Traefik logs
networks: networks:
default: default:
driver: bridge driver: bridge