Ensure proper directory configuration
This commit is contained in:
parent
3021b68b19
commit
d591e1620e
|
|
@ -1,38 +1,52 @@
|
|||
---
|
||||
- name: Ensure Pangolin directory exists
|
||||
ansible.builtin.file:
|
||||
path: /home/ubuntu/pangolin
|
||||
path: "/home/{{ ansible_user }}/compose_projects/pangolin"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
register: compose_dir
|
||||
|
||||
- name: Ensure Pangolin config directory exists
|
||||
ansible.builtin.file:
|
||||
path: /home/ubuntu/pangolin/pangolin_config
|
||||
path: "{{ compose_dir.path }}/pangolin_config"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
register: pangolin_config
|
||||
|
||||
- name: Template Pangolin config file
|
||||
ansible.builtin.template:
|
||||
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
|
||||
ansible.builtin.file:
|
||||
path: /home/ubuntu/pangolin/config/traefik
|
||||
path: "{{ pangolin_config.path }}/traefik"
|
||||
mode: '0755'
|
||||
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
|
||||
ansible.builtin.template:
|
||||
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
|
||||
ansible.builtin.template:
|
||||
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
|
||||
ansible.builtin.template:
|
||||
src: docker-compose.yml.j2
|
||||
dest: /home/ubuntu/pangolin/docker-compose.yml
|
||||
dest: "{{ compose_dir.path }}/docker-compose.yml"
|
||||
register: pangolin_compose_template
|
||||
|
||||
- name: Check if Pangolin container is running
|
||||
|
|
@ -63,22 +77,25 @@
|
|||
ignore_errors: true
|
||||
|
||||
- name: Start Pangolin and Gerbil with Docker Compose (force recreate if needed)
|
||||
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
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ compose_dir.path }}"
|
||||
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
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ docker_compose_status.stdout_lines }}"
|
||||
msg: "{{ docker_compose_status }}"
|
||||
|
||||
- name: "Assert that mandatory variables are defined and not default"
|
||||
ansible.builtin.assert:
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ services:
|
|||
container_name: pangolin
|
||||
restart: unless-stopped
|
||||
volumes:
|
||||
- ./pangolin_config:/app/config
|
||||
- {{ pangolin_config.path }}:/app/config
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-f", "http://localhost:3001/api/v1/"]
|
||||
interval: "3s"
|
||||
|
|
@ -24,7 +24,7 @@ services:
|
|||
- --remoteConfig=http://pangolin:3001/api/v1/gerbil/get-config
|
||||
- --reportBandwidthTo=http://pangolin:3001/api/v1/gerbil/receive-bandwidth
|
||||
volumes:
|
||||
- ./gerbil_config/:/var/config
|
||||
- {{ gerbil_config.path }}:/var/config
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
- SYS_MODULE
|
||||
|
|
@ -44,9 +44,9 @@ services:
|
|||
command:
|
||||
- --configFile=/etc/traefik/traefik_config.yml
|
||||
volumes:
|
||||
- ./config/traefik:/etc/traefik:ro # Volume to store the Traefik configuration
|
||||
- ./config/letsencrypt:/letsencrypt # Volume to store the Let's Encrypt certificates
|
||||
- ./config/traefik/logs:/var/log/traefik # Volume to store Traefik logs
|
||||
- {{ traefik_config.path }}:/etc/traefik:ro # Volume to store the Traefik configuration
|
||||
- {{ pangolin_config.path }}/letsencrypt:/letsencrypt # Volume to store the Let's Encrypt certificates
|
||||
- {{ traefik_config.path }}/logs:/var/log/traefik # Volume to store Traefik logs
|
||||
networks:
|
||||
default:
|
||||
driver: bridge
|
||||
|
|
|
|||
Loading…
Reference in New Issue