chore(coolify): refactored coolify role
This commit is contained in:
@@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
journal_retention_days: 21
|
||||||
|
journal_max_disk_limit: "5%"
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
- name: Ensure source directory exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ coolify_base_dir }}/source"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ coolify_owner }}"
|
||||||
|
group: "{{ coolify_group }}"
|
||||||
|
mode: "0750"
|
||||||
|
tags: coolify, configuration
|
||||||
|
|
||||||
|
- name: Check if .env exists
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ coolify_base_dir }}/source/.env"
|
||||||
|
register: coolify_env_file
|
||||||
|
tags: coolify, configuration
|
||||||
|
|
||||||
|
- name: Generate missing secrets (only for new install)
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
coolify_app_key: "{{ coolify_app_key | default(lookup('password', '/dev/null length=32 chars=ascii_letters,digits'), true) }}"
|
||||||
|
coolify_db_password: "{{ coolify_db_password | default(lookup('password', '/dev/null length=32 chars=ascii_letters,digits'), true) }}"
|
||||||
|
coolify_redis_password: "{{ coolify_redis_password | default(lookup('password', '/dev/null length=32 chars=ascii_letters,digits'), true) }}"
|
||||||
|
coolify_pusher_app_key: "{{ coolify_pusher_app_key | default(lookup('password', '/dev/null length=32 chars=ascii_letters,digits'), true) }}"
|
||||||
|
coolify_pusher_app_secret: "{{ coolify_pusher_app_secret | default(lookup('password', '/dev/null length=32 chars=ascii_letters,digits'), true) }}"
|
||||||
|
coolify_app_id: "{{ coolify_app_id | default(lookup('password', '/dev/null length=16 chars=ascii_letters,digits'), true) }}"
|
||||||
|
coolify_pusher_app_id: "{{ coolify_pusher_app_id | default(lookup('password', '/dev/null length=16 chars=ascii_letters,digits'), true) }}"
|
||||||
|
when: not coolify_env_file.stat.exists
|
||||||
|
tags: coolify, configuration
|
||||||
|
|
||||||
|
- name: Configure .env file
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: .env.j2
|
||||||
|
dest: "{{ coolify_base_dir }}/source/.env"
|
||||||
|
owner: "{{ coolify_owner }}"
|
||||||
|
group: "{{ coolify_group }}"
|
||||||
|
mode: "0640"
|
||||||
|
force: false
|
||||||
|
when: not coolify_env_file.stat.exists
|
||||||
|
tags: coolify, configuration
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
- name: Check if Coolify is installed (compose file exists)
|
||||||
|
ansible.builtin.stat:
|
||||||
|
path: "{{ coolify_base_dir }}/source/{{ coolify_compose_files[0] }}"
|
||||||
|
register: coolify_installed
|
||||||
|
tags: always
|
||||||
|
|
||||||
|
- name: Check Coolify container status
|
||||||
|
community.docker.docker_container_info:
|
||||||
|
name: "{{ item }}"
|
||||||
|
loop: "{{ coolify_container_names }}"
|
||||||
|
register: coolify_containers
|
||||||
|
when: coolify_installed.stat.exists
|
||||||
|
tags: always
|
||||||
|
|
||||||
|
- name: Set Coolify health fact
|
||||||
|
ansible.builtin.set_fact:
|
||||||
|
coolify_healthy: "{{ coolify_containers.results | selectattr('container', 'defined') | selectattr('container.State.Health.Status', 'defined') | selectattr('container.State.Health.Status', 'equalto', 'healthy') | list | length == coolify_container_names | length }}"
|
||||||
|
when: coolify_containers is defined and coolify_containers.results is defined
|
||||||
|
tags: always
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
- name: Start Coolify services
|
||||||
|
become: true
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ coolify_base_dir }}/source"
|
||||||
|
files: "{{ coolify_compose_files }}"
|
||||||
|
pull: always
|
||||||
|
state: present
|
||||||
|
wait: true
|
||||||
|
wait_timeout: 300
|
||||||
|
tags: coolify, docker, start
|
||||||
|
|
||||||
|
- name: Wait for Coolify HTTP to respond
|
||||||
|
ansible.builtin.uri:
|
||||||
|
url: "http://localhost:{{ coolify_http_port }}"
|
||||||
|
method: GET
|
||||||
|
status_code: 200
|
||||||
|
timeout: 30
|
||||||
|
body_format: json
|
||||||
|
register: coolify_health
|
||||||
|
until: coolify_health.status == 200
|
||||||
|
retries: 10
|
||||||
|
delay: 10
|
||||||
|
tags: coolify, health, start
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
- name: Stop Coolify services (compose down)
|
||||||
|
become: true
|
||||||
|
community.docker.docker_compose_v2:
|
||||||
|
project_src: "{{ coolify_base_dir }}/source"
|
||||||
|
files: "{{ coolify_compose_files }}"
|
||||||
|
state: absent
|
||||||
|
remove_orphans: true
|
||||||
|
remove_volumes: false
|
||||||
|
tags: coolify, docker, stop
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
APP_ID={{ coolify_app_id | default('') }}
|
||||||
|
APP_NAME={{ coolify_app_name | default('Coolify') }}
|
||||||
|
APP_KEY={{ coolify_app_key | default('') }}
|
||||||
|
|
||||||
|
DB_USERNAME={{ coolify_db_username | default('coolify') }}
|
||||||
|
DB_PASSWORD={{ coolify_db_password | default('') }}
|
||||||
|
|
||||||
|
REDIS_PASSWORD={{ coolify_redis_password | default('') }}
|
||||||
|
|
||||||
|
PUSHER_APP_ID={{ coolify_pusher_app_id | default('') }}
|
||||||
|
PUSHER_APP_KEY={{ coolify_pusher_app_key | default('') }}
|
||||||
|
PUSHER_APP_SECRET={{ coolify_pusher_app_secret | default('') }}
|
||||||
|
|
||||||
|
ROOT_USERNAME={{ coolify_root_username | default('') }}
|
||||||
|
ROOT_USER_EMAIL={{ coolify_root_user_email | default('') }}
|
||||||
|
ROOT_USER_PASSWORD={{ coolify_root_user_password | default('') }}
|
||||||
|
|
||||||
|
REGISTRY_URL={{ coolify_registry_url | default('ghcr.io') }}
|
||||||
Reference in New Issue
Block a user