refactor(roles/coolify): refactored coolify role

This commit is contained in:
ITQ
2026-03-19 14:41:51 +03:00
parent 8a9cc4a1ce
commit 81b623432c
12 changed files with 533 additions and 202 deletions
+44 -42
View File
@@ -3,66 +3,68 @@
ansible.builtin.assert:
that:
- coolify_state in ['present', 'absent', 'latest', 'stopped']
msg: "coolify_state must be one of: present, absent, latest, stopped"
fail_msg: >-
Invalid coolify_state '{{ coolify_state }}'.
Must be one of: present, absent, latest, stopped.
quiet: true
tags: always
- name: Detect Coolify installation status
ansible.builtin.include_tasks: detect.yaml
tags: always
- name: Ensure Docker network exists
become: true
community.docker.docker_network:
name: "{{ coolify_docker_network }}"
driver: bridge
attachable: true
state: present
tags: coolify, docker, installation
- name: Uninstall Coolify
ansible.builtin.include_tasks: delete.yaml
when: coolify_state == 'absent'
tags: coolify, deletion
- name: Install Coolify
ansible.builtin.include_tasks: install.yaml
when:
- coolify_state in ['present', 'latest']
- not coolify_installed.stat.exists
tags: coolify, installation
- name: Update Coolify
ansible.builtin.include_tasks: update.yaml
when:
- coolify_state == 'latest'
- coolify_installed.stat.exists
tags: coolify, update
- name: Ensure Configuration
ansible.builtin.include_tasks: configure.yaml
when:
- coolify_state == 'present'
- coolify_installed.stat.exists
tags: coolify, configuration
- name: Ensure Started
ansible.builtin.include_tasks: start.yaml
when:
- coolify_state == 'present'
- coolify_installed.stat.exists
tags: coolify, start
- name: Stop Coolify
ansible.builtin.include_tasks: stop.yaml
when:
- coolify_state == 'stopped'
- coolify_installed.stat.exists
- _coolify_installed
tags: coolify, stop
- name: Show status
- name: Ensure Docker network exists
become: true
community.docker.docker_network:
name: "{{ coolify_docker_network }}"
driver: bridge
state: present
when: coolify_state in ['present', 'latest']
tags: coolify, docker
- name: Install Coolify (fresh)
ansible.builtin.include_tasks: install.yaml
when:
- coolify_state in ['present', 'latest']
- not _coolify_installed
tags: coolify, installation
- name: Update Coolify (existing)
ansible.builtin.include_tasks: update.yaml
when:
- coolify_state == 'latest'
- _coolify_installed
tags: coolify, update
- name: Ensure Coolify is configured and running
when:
- coolify_state == 'present'
- _coolify_installed
tags: coolify, configuration
block:
- name: Ensure configuration is up to date
ansible.builtin.include_tasks: configure.yaml
- name: Ensure services are running
ansible.builtin.include_tasks: start.yaml
- name: Show Coolify status
ansible.builtin.debug:
msg:
- "Coolify State: {{ coolify_state }}"
- "URL: http://{{ ansible_host }}:{{ coolify_http_port }}"
- "State: {{ coolify_state }}"
- "Installed: {{ _coolify_installed }}"
- "URL: http://{{ ansible_host }}:{{ coolify_app_port }}"
when: coolify_state in ['present', 'latest']
tags: coolify, status