From 2df4349606a3e38f75dfddb1360335e49bf94752 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Thu, 20 Sep 2018 09:25:00 +0300 Subject: [PATCH] Fix matrix-corporal nginx configuration trouble in certain conditions If the playbook were to run with `--tags=setup-nginx-proxy`, it wouldn't go into `setup_corporal.yml`, which meant it wouldn't perform a bunch of `set_fact` calls which override important nginx proxy configuration. We run these variable overrides on each call now (tagged with `always`) to avoid such problems in the future. --- roles/matrix-server/tasks/main.yml | 4 ++++ roles/matrix-server/tasks/setup_corporal.yml | 7 ++----- .../matrix-server/tasks/setup_corporal_overrides.yml | 11 +++++++++++ 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 roles/matrix-server/tasks/setup_corporal_overrides.yml diff --git a/roles/matrix-server/tasks/main.yml b/roles/matrix-server/tasks/main.yml index 36346512..5975a2fc 100644 --- a/roles/matrix-server/tasks/main.yml +++ b/roles/matrix-server/tasks/main.yml @@ -42,6 +42,10 @@ - setup-all - setup-mxisd +- include: tasks/setup_corporal_overrides.yml + tags: + - always + - include: tasks/setup_corporal.yml tags: - setup-all diff --git a/roles/matrix-server/tasks/setup_corporal.yml b/roles/matrix-server/tasks/setup_corporal.yml index f2729a1e..db3edc1c 100644 --- a/roles/matrix-server/tasks/setup_corporal.yml +++ b/roles/matrix-server/tasks/setup_corporal.yml @@ -19,11 +19,8 @@ msg: "The Matrix Corporal policy provider configuration has not been set in matrix_corporal_policy_provider_config" when: "matrix_corporal_enabled and matrix_corporal_policy_provider_config == ''" -- name: Override configuration specifying where the Matrix Client API is - set_fact: - matrix_nginx_proxy_matrix_client_api_addr_with_proxy_container: "matrix-corporal:41080" - matrix_nginx_proxy_matrix_client_api_addr_sans_proxy_container: "localhost:41080" - when: "matrix_corporal_enabled" +# There are some additional initialization tasks in setup_corporal_overrides.yml, +# which need to always run, no matter what tag the playbook is running with. - name: Ensure Matrix Corporal paths exist file: diff --git a/roles/matrix-server/tasks/setup_corporal_overrides.yml b/roles/matrix-server/tasks/setup_corporal_overrides.yml new file mode 100644 index 00000000..a410f801 --- /dev/null +++ b/roles/matrix-server/tasks/setup_corporal_overrides.yml @@ -0,0 +1,11 @@ +# These overrides run with the `always` tag, +# because they're important not only for the `setup-corporal` tag, but for other tags too. +# +# We want an nginx-proxy rebuild (`--tags=setup-nginx-proxy`) to also go through here +# and be affected by these overrides. + +- name: Override configuration specifying where the Matrix Client API is + set_fact: + matrix_nginx_proxy_matrix_client_api_addr_with_proxy_container: "matrix-corporal:41080" + matrix_nginx_proxy_matrix_client_api_addr_sans_proxy_container: "localhost:41080" + when: "matrix_corporal_enabled" \ No newline at end of file