diff --git a/tasks/postgresql-config.yml b/tasks/postgresql-config.yml
index 6aab555..45e09c2 100644
--- a/tasks/postgresql-config.yml
+++ b/tasks/postgresql-config.yml
@@ -49,87 +49,81 @@
       when: postgresql_data_dir.stat.isdir is not defined
 
 - name: postgresql-config | Configuration of Deb/Ubuntu systems
-  block:
-  - name: postgresql-config | Set some postgresql configuration parameters that require a db restart
-    become: True
-    become_user: postgres
-    action: configfile path={{ psql_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
-    with_items: '{{ psql_conf_parameters }}'
-    when: item.set == 'True'
-    notify: Restart postgresql
-    tags: [ 'postgresql', 'postgres', 'pg_conf' ]
-
-  - name: postgresql-config | Set the postgresql logging configuration parameters
-    become: True
-    become_user: postgres
-    action: configfile path={{ psql_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
-    with_items: '{{ psql_log_configuration }}'
-    when: item.set == 'True'
-    notify: Reload postgresql
-    tags: [ 'postgresql', 'postgres', 'pg_conf', 'pg_conf_log' ]
-
-  - name: postgresql-config | Set the postgresql autovacuum configuration parameters
-    become: True
-    become_user: postgres
-    action: configfile path={{ psql_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
-    with_items: '{{ psql_autovacuum_configuration }}'
-    when: item.set == 'True'
-    notify: Reload postgresql
-    tags: [ 'postgresql', 'postgres', 'pg_conf', 'pg_conf_autovacuum' ]
-
-  - name: postgresql-config | Set the postgresql listen port
-    action: configfile path={{ psql_conf_dir }}/postgresql.conf key=port value="{{ psql_db_port }}"
-    register: restart_postgresql
-    tags: [ 'postgresql', 'postgres', 'pg_conf' ]
-
-  - name: postgresql-config | We want postgres listen on the public IP
-    action: configfile path={{ psql_conf_dir }}/postgresql.conf key=listen_addresses value="'*'"
-    register: restart_postgresql
-    when:
-      - psql_listen_on_ext_int
-    tags: [ 'postgresql', 'postgres', 'pg_conf' ]
-
-  - name: postgresql-config | If postgresql is only accessed from localhost make it listen only on the localhost interface
-    action: configfile path={{ psql_conf_dir }}/postgresql.conf key=listen_addresses value="'localhost'"
-    register: restart_postgresql
-    when:
-      - not psql_listen_on_ext_int
-    tags: [ 'postgresql', 'postgres', 'pg_conf' ]
-
-  - name: postgresql-config | Log the connections
-    action: configfile path={{ psql_conf_dir }}/postgresql.conf key=log_connections value="on"
-    register: restart_postgresql
-    when: psql_db_data is defined
-    tags: [ 'postgresql', 'postgres', 'pg_conf' ]
-
-  - name: postgresql-config | Log the disconnections
-    action: configfile path={{ psql_conf_dir }}/postgresql.conf key=log_disconnections value="on"
-    register: restart_postgresql
-    when: psql_db_data is defined
-    tags: [ 'postgresql', 'postgres', 'pg_conf' ]
-
-  - name: postgresql-config | Log the hostnames
-    action: configfile path={{ psql_conf_dir }}/postgresql.conf key=log_hostname value="on"
-    register: restart_postgresql
-    when:
-      - psql_listen_on_ext_int
-    tags: [ 'postgresql', 'postgres', 'pg_conf' ]
-
-  - name: postgresql-config | Set the correct permissions to the postgresql files
-    file: dest={{ psql_conf_dir }}/{{ item }} owner=root group=postgres mode=0640
-    with_items:
-      - pg_hba.conf
-      - postgresql.conf
-    tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_conf' ]
-
-  - name: postgresql-config | Restart the postgresql server after changing parameters that need a restart
-    service: name=postgresql state=restarted
-    when:
-      - restart_postgresql is defined and restart_postgresql is changed
-    ignore_errors: True
-    tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_conf' ]
-
   when: ansible_distribution_file_variety == "Debian"
+  tags: ['postgresql', 'postgres', 'pg_conf']
+  block:
+    - name: postgresql-config | Set some postgresql configuration parameters that require a db restart
+      become: true
+      become_user: postgres
+      community.postgresql.postgresql_set:
+        name: '{{ item.name }}'
+        value: "{% if item.set %}{{ item.value }}{% else %}default{% endif %}"
+      loop: '{{ psql_conf_parameters }}'
+      notify: Restart postgresql
+
+    - name: postgresql-config | Set the postgresql logging configuration parameters
+      become: true
+      become_user: postgres
+      community.postgresql.postgresql_set:
+        name: '{{ item.name }}'
+        value: "{% if item.set %}{{ item.value }}{% else %}default{% endif %}"
+      loop: '{{ psql_log_configuration }}'
+      notify: Reload postgresql
+      tags: ['postgresql', 'postgres', 'pg_conf', 'pg_conf_log']
+
+    - name: postgresql-config | Set the postgresql autovacuum configuration parameters
+      become: true
+      become_user: postgres
+      community.postgresql.postgresql_set:
+        name: '{{ item.name }}'
+        value: "{% if item.set %}{{ item.value }}{% else %}default{% endif %}"
+      loop: '{{ psql_autovacuum_configuration }}'
+      notify: Reload postgresql
+      tags: ['postgresql', 'postgres', 'pg_conf', 'pg_conf_autovacuum']
+
+    - name: postgresql-config | Set the postgresql listen port
+      become: true
+      become_user: postgres
+      community.postgresql.postgresql_set:
+        name: 'port'
+        value: "{% if psql_listen_on_ext_int %}{{ psql_db_port }}{% else %}default{% endif %}"
+      notify: Restart postgresql
+
+    - name: postgresql-config | We want postgres listen on the public IP
+      become: true
+      become_user: postgres
+      community.postgresql.postgresql_set:
+        name: 'listen_addresses'
+        value: "{% if psql_listen_on_ext_int %}*{% else %}default{% endif %}"
+      notify: Restart postgresql
+
+    - name: postgresql-config | Log the connections
+      become: true
+      become_user: postgres
+      community.postgresql.postgresql_set:
+        name: 'log_connections'
+        value: "{% if psql_db_data is defined %}on{% else %}default{% endif %}"
+      notify: Reload postgresql
+
+    - name: postgresql-config | Log the disconnections
+      become: true
+      become_user: postgres
+      community.postgresql.postgresql_set:
+        name: 'log_disconnections'
+        value: "{% if psql_db_data is defined %}on{% else %}default{% endif %}"
+      notify: Reload postgresql
+
+    - name: postgresql-config | Log the hostnames
+      become: true
+      become_user: postgres
+      community.postgresql.postgresql_set:
+        name: 'log_hostname'
+        value: "{% if psql_listen_on_ext_int %}{{ psql_db_port }}{% else %}default{% endif %}"
+      notify: Reload postgresql
+
+    - name: postgresql-config | Flush flush_handlers Restart PostgreSQL
+      ansible.builtin.meta: flush_handlers
+      tags: ['postgresql', 'postgres', 'pg_hba', 'pg_conf']
 
 - name: postgresql-config | Data directory for EL
   block: 
@@ -188,7 +182,7 @@
     command: restorecon -vR {{ psql_log_dir }}
 
   - name: postgresql-config | Set some postgresql configuration parameters that require a db restart
-    become: True
+    become: true
     become_user: postgres
     action: configfile path={{ psql_el_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
     with_items: '{{ psql_conf_parameters }}'
@@ -197,7 +191,7 @@
     tags: [ 'postgresql', 'postgres', 'pg_conf' ]
 
   - name: postgresql-config | Set the postgresql logging configuration parameters
-    become: True
+    become: true
     become_user: postgres
     action: configfile path={{ psql_el_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
     with_items: '{{ psql_log_configuration }}'
@@ -206,7 +200,7 @@
     tags: [ 'postgresql', 'postgres', 'pg_conf', 'pg_conf_log' ]
 
   - name: postgresql-config | Set the postgresql autovacuum configuration parameters
-    become: True
+    become: true
     become_user: postgres
     action: configfile path={{ psql_el_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
     with_items: '{{ psql_autovacuum_configuration }}'