diff --git a/tasks/main.yml b/tasks/main.yml
index eace13a444213166b0dda8582fb19fa0cee91eed..a070c620e9b53f7177128030ca4df5bb9681624a 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,4 +1,10 @@
 ---
+- name: Gather facts about db host
+  gather_facts:
+  delegate_to: "{{ keycloak_pgdb_host }}"
+  delegate_facts: True
+  when: "'ansible_default_ipv4' not in hostvars[keycloak_pgdb_host]"
+
 - name: Import Azul public key (for Zulu JRE)
   apt_key:
     id: B1998361219BD9C9