From ac61ee17770c63387365c552f23f9fc330f2125c Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 31 Jul 2020 13:07:47 +0200 Subject: [PATCH] Use the correct task to set the selinux context. --- tasks/postgresql-config.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tasks/postgresql-config.yml b/tasks/postgresql-config.yml index b677438..372934d 100644 --- a/tasks/postgresql-config.yml +++ b/tasks/postgresql-config.yml @@ -87,8 +87,14 @@ creates: '{{ psql_el_data_dir }}/base' when: postgresql_data_dir.stat.isdir is not defined - - name: Fix the SELinux rules - shell: semanage fcontext -a -a -t postgresql_db_t "{{ psql_el_base_dir }}(/.*)?" && restorecon -vR {{ psql_el_base_dir }} + - name: Fix the SELinux context for the new data directory + sefcontext: + target: '{{ psql_el_base_dir }}(/.*)?' + setype: postgresql_db_t + state: present + + - name: Restore the SELinux context + command: restorecon -vR {{ psql_el_base_dir }} - name: Start the postgresql service that will use the new data directory service: name='postgresql-{{ psql_version }}' state=started @@ -105,8 +111,14 @@ - name: Create the postgresql log directory file: dest={{ psql_log_dir }} state=directory owner=postgres group=postgres mode='0750' - - name: Fix the SELinux rules for the postgresql log directory - shell: semanage fcontext -a -a -t postgresql_db_t "{{ psql_log_dir }}(/.*)?" && restorecon -vR {{ psql_log_dir }} + - name: Fix the SELinux context for the postgresql log directory + sefcontext: + target: '{{ psql_log_dir }}(/.*)?' + setype: postgresql_db_t + state: present + + - name: Fix the SELinux context for the postgresql log directory + command: restorecon -vR {{ psql_log_dir }} - name: Set some postgresql configuration parameters that require a db restart become: True