From b4a84c41f9a331296551419d3ec0baa5122f6681 Mon Sep 17 00:00:00 2001 From: Greg Dubicki Date: Sun, 10 Jul 2022 10:07:56 +0200 Subject: [PATCH] Simplify and explain the code --- tasks/variables.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/tasks/variables.yml b/tasks/variables.yml index cec21d3..cb5610b 100644 --- a/tasks/variables.yml +++ b/tasks/variables.yml @@ -52,18 +52,16 @@ - name: Define postgresql_log_dir. set_fact: + # postgresql_global_config_options is an array but its keys are unique, so it can be converted to dict, + # to easily get the value under the 'log_directory' key postgresql_log_dir: "{{ (postgresql_global_config_options | items2dict(key_name='option', value_name='value')).log_directory }}" -- name: Define postgresql_log_dir_is_absolute. - set_fact: - postgresql_log_dir_is_absolute: '{{ postgresql_log_dir | regex_search("^/.*") != "" }}' - -- name: Define postgresql_effective_log_dir, if postgresql_log_dir_is_absolute +- name: Define postgresql_effective_log_dir, if postgresql_log_dir is absolute set_fact: postgresql_effective_log_dir: '{{ postgresql_log_dir }}' - when: postgresql_log_dir_is_absolute + when: postgresql_log_dir is regex("^/.*") -- name: Define postgresql_effective_log_dir, if not postgresql_log_dir_is_absolute +- name: Define postgresql_effective_log_dir, if postgresql_log_dir is relative set_fact: postgresql_effective_log_dir: '{{ postgresql_data_dir }}/{{ postgresql_log_dir }}' - when: not postgresql_log_dir_is_absolute + when: postgresql_log_dir is not regex("^/.*")