diff --git a/roles/custom/matrix-client-commet/tasks/setup_install.yml b/roles/custom/matrix-client-commet/tasks/setup_install.yml index 3f9482420..4eef36480 100644 --- a/roles/custom/matrix-client-commet/tasks/setup_install.yml +++ b/roles/custom/matrix-client-commet/tasks/setup_install.yml @@ -16,58 +16,6 @@ - "{{ matrix_client_commet_base_path }}" - "{{ matrix_client_commet_config_path }}" -# Self-build tasks — skipped when using a pre-built registry image -- name: Check Commet git remote configuration - ansible.builtin.command: - cmd: git -C "{{ matrix_client_commet_container_src_path }}" remote get-url origin - register: matrix_client_commet_git_remote_check - failed_when: false - changed_when: false - when: matrix_client_commet_container_image_self_build | bool - -- name: Remove Commet source directory if git remote is misconfigured - ansible.builtin.file: - path: "{{ matrix_client_commet_container_src_path }}" - state: absent - when: matrix_client_commet_container_image_self_build | bool and matrix_client_commet_git_remote_check.rc != 0 - become: true - -- name: Ensure Commet repository is present on self-build - ansible.builtin.git: - repo: "{{ matrix_client_commet_container_image_self_build_repo }}" - dest: "{{ matrix_client_commet_container_src_path }}" - version: "{{ matrix_client_commet_version }}" - force: "yes" - become: true - become_user: "{{ matrix_user_name }}" - register: matrix_client_commet_git_pull_results - -- name: Capture git hash - ansible.builtin.command: - cmd: git -C {{ matrix_client_commet_container_src_path }} rev-parse --short HEAD - register: matrix_client_commet_git_hash_result - changed_when: false - when: matrix_client_commet_container_image_self_build | bool - -- name: Set git hash fact - ansible.builtin.set_fact: - matrix_client_commet_container_image_self_build_git_hash: "{{ matrix_client_commet_git_hash_result.stdout | trim }}" - when: matrix_client_commet_container_image_self_build | bool - -- name: Build Commet Docker image - ansible.builtin.command: - cmd: |- - {{ devture_systemd_docker_base_host_command_docker }} buildx build - --tag={{ matrix_client_commet_container_image }} - --build-arg GIT_HASH={{ matrix_client_commet_container_image_self_build_git_hash }} - --build-arg VERSION_TAG={{ matrix_client_commet_container_image_self_build_version_tag }} - --build-arg BUILD_DATE={{ ansible_date_time.epoch }} - --file={{ matrix_client_commet_container_src_path }}/Dockerfile - {{ matrix_client_commet_container_src_path }} - changed_when: true - register: matrix_client_commet_image_build_result - when: matrix_client_commet_container_image_self_build | bool - - name: Ensure Commet container image is pulled community.docker.docker_image: name: "{{ matrix_client_commet_container_image }}" @@ -80,6 +28,55 @@ delay: "{{ devture_playbook_help_container_retries_delay }}" until: matrix_client_commet_image_pull_result is not failed +- when: "matrix_client_commet_container_image_self_build | bool" + block: + - name: Check Commet git remote configuration + ansible.builtin.command: + cmd: git -C "{{ matrix_client_commet_container_src_path }}" remote get-url origin + register: matrix_client_commet_git_remote_check + failed_when: false + changed_when: false + + - name: Remove Commet source directory if git remote is misconfigured + ansible.builtin.file: + path: "{{ matrix_client_commet_container_src_path }}" + state: absent + when: matrix_client_commet_git_remote_check.rc != 0 + become: true + + - name: Ensure Commet repository is present on self-build + ansible.builtin.git: + repo: "{{ matrix_client_commet_container_image_self_build_repo }}" + dest: "{{ matrix_client_commet_container_src_path }}" + version: "{{ matrix_client_commet_version }}" + force: "yes" + become: true + become_user: "{{ matrix_user_name }}" + register: matrix_client_commet_git_pull_results + + - name: Capture git hash + ansible.builtin.command: + cmd: git -C {{ matrix_client_commet_container_src_path }} rev-parse --short HEAD + register: matrix_client_commet_git_hash_result + changed_when: false + + - name: Set git hash fact + ansible.builtin.set_fact: + matrix_client_commet_container_image_self_build_git_hash: "{{ matrix_client_commet_git_hash_result.stdout | trim }}" + + - name: Ensure Commet container image is built + ansible.builtin.command: + cmd: |- + {{ devture_systemd_docker_base_host_command_docker }} buildx build + --tag={{ matrix_client_commet_container_image }} + --build-arg GIT_HASH={{ matrix_client_commet_container_image_self_build_git_hash }} + --build-arg VERSION_TAG={{ matrix_client_commet_container_image_self_build_version_tag }} + --build-arg BUILD_DATE={{ ansible_date_time.epoch }} + --file={{ matrix_client_commet_container_src_path }}/Dockerfile + {{ matrix_client_commet_container_src_path }} + changed_when: true + register: matrix_client_commet_image_build_result + - name: Ensure Commet global_config.json is installed ansible.builtin.template: src: "{{ role_path }}/templates/global_config.json.j2"