Skip to content

Commit

Permalink
moves matrix_dendrite_container_image_self_build to a conditional blo…
Browse files Browse the repository at this point in the history
…ck, similar to synapse
  • Loading branch information
ibeckermayer committed May 10, 2023
1 parent 2bd94a5 commit 7249c78
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions roles/custom/matrix-dendrite/tasks/setup_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@
delay: "{{ devture_playbook_help_container_retries_delay }}"
until: result is not failed

- name: Ensure Dendrite repository is present on self-build
ansible.builtin.git:
repo: "{{ matrix_dendrite_container_image_self_build_repo }}"
dest: "{{ matrix_dendrite_docker_src_files_path }}"
version: "{{ matrix_dendrite_docker_image.split(':')[1] }}"
force: "yes"
become: true
become_user: "{{ matrix_user_username }}"
register: matrix_dendrite_git_pull_results
when: "matrix_dendrite_container_image_self_build | bool"

# We do this so that the signing key would get generated.
# We don't use the `docker_container` module, because using it with `cap_drop` requires
# a very recent version, which is not available for a lot of people yet.
Expand Down Expand Up @@ -88,10 +77,27 @@
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

- name: Ensure Dendrite Docker image is built
ansible.builtin.command:
cmd: "{{ devture_systemd_docker_base_host_command_docker }} build -t {{ matrix_dendrite_docker_image }} {{ matrix_dendrite_docker_src_files_path }}"
when: "matrix_dendrite_container_image_self_build | bool"
- when: "matrix_dendrite_container_image_self_build | bool"
block:
- name: Ensure Dendrite repository is present on self-build
ansible.builtin.git:
repo: "{{ matrix_dendrite_container_image_self_build_repo }}"
dest: "{{ matrix_dendrite_docker_src_files_path }}"
version: "{{ matrix_dendrite_docker_image.split(':')[1] }}"
force: "yes"
become: true
become_user: "{{ matrix_user_username }}"
register: matrix_dendrite_git_pull_results

- name: Check if Dendrite Docker image exists
ansible.builtin.command: "{{ devture_systemd_docker_base_host_command_docker }} images --quiet --filter 'reference={{ matrix_dendrite_docker_image }}'"
register: matrix_dendrite_docker_image_check_result
changed_when: false

- name: Ensure Dendrite Docker image is built
ansible.builtin.command:
cmd: "{{ devture_systemd_docker_base_host_command_docker }} build -t {{ matrix_dendrite_docker_image }} {{ matrix_dendrite_docker_src_files_path }}"
when: "matrix_dendrite_git_pull_results.changed | bool or matrix_dendrite_docker_image_check_result.stdout == ''"

- name: Ensure Dendrite container network is created
community.general.docker_network:
Expand Down

0 comments on commit 7249c78

Please sign in to comment.