diff --git a/defaults/main.yml b/defaults/main.yml
index 5f9fbeedd2d75dec7380141a981c2424eddbeacc..569ce6442ffb35e0e68f58c77ed0eb06c28cdab0 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -14,8 +14,8 @@ funkwhale_database_managed: true
funkwhale_database_local: true
funkwhale_database_name: funkwhale
funkwhale_database_user: funkwhale
-# the DB host as per your ansible inventory
-funkwhale_database_host_ansible: localhost
+# the DB host as per your ansible inventory. No delegation is used if left empty
+funkwhale_database_host_ansible:
# the DB FQDN or IP for funkwhale connector configuration (ex: pg01.local)
funkwhale_database_host_app: localhost
funkwhale_database_port: 5432
diff --git a/tasks/db.yml b/tasks/db.yml
index 230bad933f0bbb1428fbe701d9837c97b293c771..23844b20d6f6ac87fd3c58a9686145dc5a6798e4 100644
--- a/tasks/db.yml
+++ b/tasks/db.yml
@@ -13,26 +13,25 @@
name: postgresql
state: started
-- name: "Create {{ funkwhale_database_user }} database user on {{ funkwhale_database_host_ansible }} (local / passwordless)"
+- name: "Create {{ funkwhale_database_user }} database user on {{ funkwhale_database_host_ansible or inventory_hostname }} (local / passwordless)"
become: true
become_user: postgres
- when: funkwhale_database_managed and funkwhale_database_host_ansible == 'localhost'
+ when: funkwhale_database_managed and funkwhale_database_host_ansible == none
postgresql_user:
name: "{{ funkwhale_database_user }}"
login_user: postgres
- delegate_to: "{{ funkwhale_database_host_ansible }}"
- name: "Create {{ funkwhale_database_user }} database user on {{ funkwhale_database_host_ansible }} (remote / with password)"
become: true
become_user: postgres
- when: funkwhale_database_managed and funkwhale_database_host_ansible != 'localhost'
+ when: funkwhale_database_managed and funkwhale_database_host_ansible != none
postgresql_user:
name: "{{ funkwhale_database_user }}"
password: "{{ funkwhale_database_password }}"
login_user: postgres
- delegate_to: "{{ funkwhale_database_host_ansible }}"
+ delegate_to: "{{ funkwhale_database_host_ansible or inventory_hostname }}"
-- name: "Create {{ funkwhale_database_name }} database on {{ funkwhale_database_host_ansible }}"
+- name: "Create {{ funkwhale_database_name }} database on {{ funkwhale_database_host_ansible or inventory_hostname}}"
become: true
become_user: postgres
when: funkwhale_database_managed
@@ -42,7 +41,7 @@
owner: "{{ funkwhale_database_user }}"
encoding: UTF-8
template: template0
- delegate_to: "{{ funkwhale_database_host_ansible }}"
+ delegate_to: "{{ funkwhale_database_host_ansible or inventory_hostname }}"
- name: set up pgsql extensions
become: yes
@@ -55,6 +54,6 @@
loop: ['unaccent', 'citext']
loop_control:
loop_var: myext
- delegate_to: "{{ funkwhale_database_host_ansible }}"
+ delegate_to: "{{ funkwhale_database_host_ansible or inventory_hostname }}"
...