From 0f2e568b3098e63ca08af94416d0da37ce4a56ac Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sun, 12 Mar 2023 09:56:53 +0200 Subject: [PATCH] Add validation tasks to matrix-synapse-auto-compressor --- .../matrix-synapse-auto-compressor/defaults/main.yml | 2 +- .../matrix-synapse-auto-compressor/tasks/main.yml | 3 +++ .../tasks/validate_config.yml | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 roles/custom/matrix-synapse-auto-compressor/tasks/validate_config.yml diff --git a/roles/custom/matrix-synapse-auto-compressor/defaults/main.yml b/roles/custom/matrix-synapse-auto-compressor/defaults/main.yml index 99fb272f..8de4097e 100644 --- a/roles/custom/matrix-synapse-auto-compressor/defaults/main.yml +++ b/roles/custom/matrix-synapse-auto-compressor/defaults/main.yml @@ -27,7 +27,7 @@ matrix_synapse_auto_compressor_systemd_required_services_list: ['docker.service' matrix_synapse_auto_compressor_systemd_wanted_services_list: [] matrix_synapse_auto_compressor_database_username: 'synapse' -matrix_synapse_auto_compressor_database_password: 'some-password' +matrix_synapse_auto_compressor_database_password: '' matrix_synapse_auto_compressor_database_hostname: '' matrix_synapse_auto_compressor_database_port: 5432 matrix_synapse_auto_compressor_database_name: 'synapse' diff --git a/roles/custom/matrix-synapse-auto-compressor/tasks/main.yml b/roles/custom/matrix-synapse-auto-compressor/tasks/main.yml index b3549bd6..2cce1f12 100644 --- a/roles/custom/matrix-synapse-auto-compressor/tasks/main.yml +++ b/roles/custom/matrix-synapse-auto-compressor/tasks/main.yml @@ -1,6 +1,9 @@ --- - block: + - when: matrix_synapse_auto_compressor_enabled | bool + ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml" + - when: matrix_synapse_auto_compressor_enabled | bool ansible.builtin.include_tasks: "{{ role_path }}/tasks/install.yml" tags: diff --git a/roles/custom/matrix-synapse-auto-compressor/tasks/validate_config.yml b/roles/custom/matrix-synapse-auto-compressor/tasks/validate_config.yml new file mode 100644 index 00000000..b0dbfab0 --- /dev/null +++ b/roles/custom/matrix-synapse-auto-compressor/tasks/validate_config.yml @@ -0,0 +1,10 @@ +--- + +- name: Fail if required matrix-synapse-auto-compressor settings not defined + ansible.builtin.fail: + msg: > + You need to define a required configuration setting (`{{ item }}`). + when: "vars[item] == ''" + with_items: + - matrix_synapse_auto_compressor_database_hostname + - matrix_synapse_auto_compressor_database_password