4
0
mirror of https://github.com/spantaleev/matrix-docker-ansible-deploy.git synced 2026-05-19 12:28:03 +00:00

Modernise Draupnir Role ansible modules and update restart logic (#5187)

This commit is contained in:
Catalan Lover
2026-05-04 15:15:18 +02:00
committed by GitHub
parent c0ba02c83f
commit 75f097e55c
8 changed files with 70 additions and 26 deletions

View File

@@ -38,11 +38,9 @@
register: matrix_bot_draupnir_support_files_result
- name: Ensure Draupnir Docker image is pulled
community.docker.docker_image:
community.docker.docker_image_pull:
name: "{{ matrix_bot_draupnir_container_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_bot_draupnir_container_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_bot_draupnir_container_image_force_pull }}"
pull: always
when: "not matrix_bot_draupnir_container_image_self_build | bool"
register: matrix_bot_draupnir_container_image_pull_result
retries: "{{ devture_playbook_help_container_retries_count }}"
@@ -61,15 +59,18 @@
when: "matrix_bot_draupnir_container_image_self_build | bool"
- name: Ensure Draupnir Docker image is built
community.docker.docker_image:
# Using docker_image_build with BuildKit for modern, efficient builds.
# Rebuild when the git checkout advanced to a new commit; otherwise keep the build idempotent.
# Technically the idempotency of rebuilds is more that if a build has already been executed for that name:tag
# then we won't rebuild while in idempotent mode even if git moved. That's what the force rebuild logic is for.
community.docker.docker_image_build:
name: "{{ matrix_bot_draupnir_container_image }}"
source: build
force_source: "{{ matrix_bot_draupnir_git_pull_results.changed }}"
build:
dockerfile: Dockerfile
path: "{{ matrix_bot_draupnir_container_src_files_path }}"
pull: true
dockerfile: Dockerfile
path: "{{ matrix_bot_draupnir_container_src_files_path }}"
pull: true
rebuild: "{{ 'always' if matrix_bot_draupnir_git_pull_results.changed | bool else 'never' }}"
when: "matrix_bot_draupnir_container_image_self_build | bool"
register: matrix_bot_draupnir_container_image_build_result
- name: Ensure matrix-bot-draupnir config installed
ansible.builtin.copy:
@@ -113,7 +114,8 @@
or matrix_bot_draupnir_config_result.changed | default(false)
or matrix_bot_draupnir_systemd_service_result.changed | default(false)
or matrix_bot_draupnir_container_image_pull_result.changed | default(false)
or matrix_bot_draupnir_container_image_force_pull | bool
or matrix_bot_draupnir_container_image_build_result.changed | default(false)
or matrix_bot_draupnir_force_restart | bool
}}
- name: Ensure matrix-bot-draupnir.service restarted, if necessary

View File

@@ -37,6 +37,7 @@
- {'old': 'matrix_bot_draupnir_docker_image_registry_prefix_upstream', 'new': 'matrix_bot_draupnir_container_image_registry_prefix_upstream'}
- {'old': 'matrix_bot_draupnir_docker_image_registry_prefix_upstream_default', 'new': 'matrix_bot_draupnir_container_image_registry_prefix_upstream_default'}
- {'old': 'matrix_bot_draupnir_docker_src_files_path', 'new': 'matrix_bot_draupnir_container_src_files_path'}
- {'old': 'matrix_bot_draupnir_container_image_force_pull', 'new': '<removed> (No longer needed due to new docker module doing this natively only if needed.)'}
- name: Fail if required matrix-bot-draupnir variables are undefined
ansible.builtin.fail: