From e3b4622ac838db4a023400c09bb409dc676fe9b6 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sat, 18 May 2019 06:36:54 +0900 Subject: [PATCH] Split Synapse extension tasks into install/uninstall files --- .../tasks/ext/rest-auth/setup-install.yml | 30 ++++++++++++ .../tasks/ext/rest-auth/setup-uninstall.yml | 6 +++ .../tasks/ext/rest-auth/setup.yml | 49 ++----------------- .../ext/shared-secret-auth/setup-install.yml | 30 ++++++++++++ .../shared-secret-auth/setup-uninstall.yml | 6 +++ .../tasks/ext/shared-secret-auth/setup.yml | 49 ++----------------- 6 files changed, 80 insertions(+), 90 deletions(-) create mode 100644 roles/matrix-synapse/tasks/ext/rest-auth/setup-install.yml create mode 100644 roles/matrix-synapse/tasks/ext/rest-auth/setup-uninstall.yml create mode 100644 roles/matrix-synapse/tasks/ext/shared-secret-auth/setup-install.yml create mode 100644 roles/matrix-synapse/tasks/ext/shared-secret-auth/setup-uninstall.yml diff --git a/roles/matrix-synapse/tasks/ext/rest-auth/setup-install.yml b/roles/matrix-synapse/tasks/ext/rest-auth/setup-install.yml new file mode 100644 index 00000000..05429ca3 --- /dev/null +++ b/roles/matrix-synapse/tasks/ext/rest-auth/setup-install.yml @@ -0,0 +1,30 @@ +--- + +- name: Fail if REST Auth endpoint not configured + fail: + msg: "You have enabled the REST Auth password provider, but have not configured its endpoint in the `matrix_synapse_ext_password_provider_rest_auth_endpoint` variable. Consult the documentation." + when: "matrix_synapse_ext_password_provider_rest_auth_endpoint == ''" + +- name: Download matrix-synapse-rest-auth + get_url: + url: "{{ matrix_synapse_ext_password_provider_rest_auth_download_url }}" + dest: "{{ matrix_synapse_ext_path }}/rest_auth_provider.py" + force: true + mode: 0440 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_username }}" + +- set_fact: + matrix_synapse_password_providers_enabled: true + +- set_fact: + matrix_synapse_container_additional_volumes: > + {{ matrix_synapse_container_additional_volumes }} + + + {{ [{'src': '{{ matrix_synapse_ext_path }}/rest_auth_provider.py', 'dst': '{{ matrix_synapse_in_container_python_packages_path }}/rest_auth_provider.py', 'options': 'ro'}] }} + +- set_fact: + matrix_synapse_additional_loggers: > + {{ matrix_synapse_additional_loggers }} + + + {{ [{'name': 'rest_auth_provider', 'level': 'INFO'}] }} diff --git a/roles/matrix-synapse/tasks/ext/rest-auth/setup-uninstall.yml b/roles/matrix-synapse/tasks/ext/rest-auth/setup-uninstall.yml new file mode 100644 index 00000000..be8ad600 --- /dev/null +++ b/roles/matrix-synapse/tasks/ext/rest-auth/setup-uninstall.yml @@ -0,0 +1,6 @@ +--- + +- name: Ensure matrix-synapse-rest-auth doesn't exist + file: + path: "{{ matrix_synapse_ext_path }}/rest_auth_provider.py" + state: absent diff --git a/roles/matrix-synapse/tasks/ext/rest-auth/setup.yml b/roles/matrix-synapse/tasks/ext/rest-auth/setup.yml index 9cdb5a2d..5e546e9f 100644 --- a/roles/matrix-synapse/tasks/ext/rest-auth/setup.yml +++ b/roles/matrix-synapse/tasks/ext/rest-auth/setup.yml @@ -1,48 +1,7 @@ --- -# -# Tasks related to setting up matrix-synapse-rest-auth -# +- import_tasks: "{{ role_path }}/tasks/ext/rest-auth/setup-install.yml" + when: matrix_synapse_ext_password_provider_rest_auth_enabled -- name: Fail if REST Auth enabled, but endpoint not configured - fail: - msg: "You have enabled the REST Auth password provider, but have not configured its endpoint in the `matrix_synapse_ext_password_provider_rest_auth_endpoint` variable. Consult the documentation." - when: "matrix_synapse_ext_password_provider_rest_auth_enabled and matrix_synapse_ext_password_provider_rest_auth_endpoint == ''" - -- name: Download matrix-synapse-rest-auth - get_url: - url: "{{ matrix_synapse_ext_password_provider_rest_auth_download_url }}" - dest: "{{ matrix_synapse_ext_path }}/rest_auth_provider.py" - force: true - mode: 0440 - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_username }}" - when: "matrix_synapse_ext_password_provider_rest_auth_enabled" - -- set_fact: - matrix_synapse_password_providers_enabled: true - when: "matrix_synapse_ext_password_provider_rest_auth_enabled" - -- set_fact: - matrix_synapse_container_additional_volumes: > - {{ matrix_synapse_container_additional_volumes }} - + - {{ [{'src': '{{ matrix_synapse_ext_path }}/rest_auth_provider.py', 'dst': '{{ matrix_synapse_in_container_python_packages_path }}/rest_auth_provider.py', 'options': 'ro'}] }} - when: "matrix_synapse_ext_password_provider_rest_auth_enabled" - -- set_fact: - matrix_synapse_additional_loggers: > - {{ matrix_synapse_additional_loggers }} - + - {{ [{'name': 'rest_auth_provider', 'level': 'INFO'}] }} - when: "matrix_synapse_ext_password_provider_rest_auth_enabled" - -# -# Tasks related to getting rid of matrix-synapse-rest-auth (if it was previously enabled) -# - -- name: Ensure matrix-synapse-rest-auth doesn't exist - file: - path: "{{ matrix_synapse_ext_path }}/rest_auth_provider.py" - state: absent - when: "not matrix_synapse_ext_password_provider_rest_auth_enabled" \ No newline at end of file +- import_tasks: "{{ role_path }}/tasks/ext/rest-auth/setup-uninstall.yml" + when: "not matrix_synapse_ext_password_provider_rest_auth_enabled" diff --git a/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup-install.yml b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup-install.yml new file mode 100644 index 00000000..128cba3c --- /dev/null +++ b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup-install.yml @@ -0,0 +1,30 @@ +--- + +- name: Fail if Shared Secret Auth secret not set + fail: + msg: "Shared Secret Auth is enabled, but no secret has been set in matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret" + when: "matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret == ''" + +- name: Download matrix-synapse-shared-secret-auth + get_url: + url: "{{ matrix_synapse_ext_password_provider_shared_secret_auth_download_url }}" + dest: "{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py" + force: true + mode: 0440 + owner: "{{ matrix_user_username }}" + group: "{{ matrix_user_username }}" + +- set_fact: + matrix_synapse_password_providers_enabled: true + +- set_fact: + matrix_synapse_container_additional_volumes: > + {{ matrix_synapse_container_additional_volumes }} + + + {{ [{'src': '{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py', 'dst': '{{ matrix_synapse_in_container_python_packages_path }}/shared_secret_authenticator.py', 'options': 'ro'}] }} + +- set_fact: + matrix_synapse_additional_loggers: > + {{ matrix_synapse_additional_loggers }} + + + {{ [{'name': 'shared_secret_authenticator', 'level': 'INFO'}] }} diff --git a/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup-uninstall.yml b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup-uninstall.yml new file mode 100644 index 00000000..e564909e --- /dev/null +++ b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup-uninstall.yml @@ -0,0 +1,6 @@ +--- + +- name: Ensure matrix-synapse-shared-secret-auth doesn't exist + file: + path: "{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py" + state: absent diff --git a/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup.yml b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup.yml index 34680add..a541ab15 100644 --- a/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup.yml +++ b/roles/matrix-synapse/tasks/ext/shared-secret-auth/setup.yml @@ -1,48 +1,7 @@ --- -# -# Tasks related to setting up matrix-synapse-shared-secret-auth -# +- import_tasks: "{{ role_path }}/tasks/ext/shared-secret-auth/setup-install.yml" + when: matrix_synapse_ext_password_provider_shared_secret_auth_enabled -- name: Fail if Shared Secret Auth enabled, but no secret set - fail: - msg: "Shared Secret Auth is enabled, but no secret has been set in matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret" - when: "matrix_synapse_ext_password_provider_shared_secret_auth_enabled and matrix_synapse_ext_password_provider_shared_secret_auth_shared_secret == ''" - -- name: Download matrix-synapse-shared-secret-auth - get_url: - url: "{{ matrix_synapse_ext_password_provider_shared_secret_auth_download_url }}" - dest: "{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py" - force: true - mode: 0440 - owner: "{{ matrix_user_username }}" - group: "{{ matrix_user_username }}" - when: "matrix_synapse_ext_password_provider_shared_secret_auth_enabled" - -- set_fact: - matrix_synapse_password_providers_enabled: true - when: "matrix_synapse_ext_password_provider_shared_secret_auth_enabled" - -- set_fact: - matrix_synapse_container_additional_volumes: > - {{ matrix_synapse_container_additional_volumes }} - + - {{ [{'src': '{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py', 'dst': '{{ matrix_synapse_in_container_python_packages_path }}/shared_secret_authenticator.py', 'options': 'ro'}] }} - when: "matrix_synapse_ext_password_provider_shared_secret_auth_enabled" - -- set_fact: - matrix_synapse_additional_loggers: > - {{ matrix_synapse_additional_loggers }} - + - {{ [{'name': 'shared_secret_authenticator', 'level': 'INFO'}] }} - when: "matrix_synapse_ext_password_provider_shared_secret_auth_enabled" - -# -# Tasks related to getting rid of matrix-synapse-shared-secret-auth (if it was previously enabled) -# - -- name: Ensure matrix-synapse-shared-secret-auth doesn't exist - file: - path: "{{ matrix_synapse_ext_path }}/shared_secret_authenticator.py" - state: absent - when: "not matrix_synapse_ext_password_provider_shared_secret_auth_enabled" \ No newline at end of file +- import_tasks: "{{ role_path }}/tasks/ext/shared-secret-auth/setup-uninstall.yml" + when: "not matrix_synapse_ext_password_provider_shared_secret_auth_enabled"