mirror of
https://github.com/RWejlgaard/pez-infra.git
synced 2026-07-04 15:46:16 +00:00
The docker_services and systemd_services roles ran their "start the service" tasks with `failed_when: false`, so a container or unit that failed to come up still reported the deploy as green. Drop it from both start tasks so a broken deploy actually fails CI. The compose/unit *copy* tasks keep `failed_when: false` — that's load-bearing for the `item is not failed` filter that skips services without a compose/unit file. Also: - Remove a duplicate "Template service .env files" task in docker_services (second copy used a hardcoded path and didn't register; first one is the one the start task reads). - Don't trigger a full fleet deploy on docs/markdown/workflow-only pushes to main — add docs/**, **/*.md and .github/** to paths-ignore. - Drop the dangling `update-freebsd` Make target (playbook doesn't exist; fleet has no FreeBSD hosts).
53 lines
2 KiB
YAML
53 lines
2 KiB
YAML
---
|
|
# Deploy Docker Compose services from the repo's services/ directory.
|
|
# Expects docker_services list in host_vars and compose files in services/<name>/.
|
|
|
|
- name: Ensure service directories exist
|
|
ansible.builtin.file:
|
|
path: "/opt/docker/{{ item }}"
|
|
state: directory
|
|
mode: '0755'
|
|
loop: "{{ docker_services | default([]) }}"
|
|
|
|
- name: Template service .env files
|
|
ansible.builtin.template:
|
|
src: "{{ docker_services_dir | default(playbook_dir + '/services') }}/{{ item }}/.env.j2"
|
|
dest: "/opt/docker/{{ item }}/.env"
|
|
mode: '0600'
|
|
loop: "{{ docker_services | default([]) }}"
|
|
when: lookup('ansible.builtin.fileglob', (docker_services_dir | default(playbook_dir + '/services')) + '/' + item + '/.env.j2') | length > 0
|
|
no_log: true
|
|
register: docker_services_env_files
|
|
|
|
- name: Copy docker-compose files
|
|
ansible.builtin.template:
|
|
src: "{{ docker_services_dir | default(playbook_dir + '/services') }}/{{ item }}/docker-compose.yml"
|
|
dest: "/opt/docker/{{ item }}/docker-compose.yml"
|
|
mode: '0644'
|
|
loop: "{{ docker_services | default([]) }}"
|
|
register: docker_services_compose_files
|
|
failed_when: false
|
|
|
|
- name: Copy service config files
|
|
ansible.posix.synchronize:
|
|
src: "{{ docker_services_dir | default(playbook_dir + '/services') }}/{{ item }}/"
|
|
dest: "/opt/docker/{{ item }}/"
|
|
rsync_opts:
|
|
- "--exclude=docker-compose.yml"
|
|
- "--exclude=README.md"
|
|
- "--exclude=.gitkeep"
|
|
- "--exclude=*.j2"
|
|
loop: "{{ docker_services | default([]) }}"
|
|
failed_when: false
|
|
|
|
- name: Start/update docker compose services
|
|
community.docker.docker_compose_v2:
|
|
project_src: "/opt/docker/{{ item.item }}"
|
|
state: present
|
|
pull: policy
|
|
loop: "{{ docker_services_compose_files.results | default([]) }}"
|
|
when: >
|
|
(item is not failed and item is changed) or
|
|
(docker_services_env_files.results | default([]) |
|
|
selectattr('item', 'equalto', item.item) |
|
|
selectattr('changed', 'equalto', true) | list | length > 0)
|