Skip to content

Commit

Permalink
Work around buggy docker_network sometimes failing to work
Browse files Browse the repository at this point in the history
If a network like `matrix-whatever` already exists for some reason,
the `docker_network` module would not create our `matrix` network.
Working around it by avoiding `docker_network` and doing it manually.

Fixes Github issue spantaleev#12
  • Loading branch information
spantaleev committed Oct 15, 2018
1 parent de3e45e commit 36658ad
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions roles/matrix-server/tasks/setup_main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,27 @@
- "{{ matrix_base_data_path }}"
- "{{ matrix_synapse_base_path }}"

- name: Ensure Matrix network is created in Docker
docker_network:
name: "{{ matrix_docker_network }}"
driver: bridge
# `docker_network` doesn't work as expected when the given network
# is a substring of a network that already exists.
#
# See:
# - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/12
# - https://github.com/ansible/ansible/issues/32926
#
# Due to that, we employ a workaround below.
#
# - name: Ensure Matrix network is created in Docker
# docker_network:
# name: "{{ matrix_docker_network }}"
# driver: bridge

- name: Check existence of Matrix network in Docker
shell:
cmd: "docker network ls -q --filter='name=^{{ matrix_docker_network }}$'"
register: result_check_docker_network
changed_when: false

- name: Create Matrix network in Docker
shell:
cmd: "docker network create --driver=bridge {{ matrix_docker_network }}"
when: "result_check_docker_network.stdout == ''"

0 comments on commit 36658ad

Please sign in to comment.