From 7930b947def355c3f3d6c38e7568cb3bc1e9bc93 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Felix=20Sch=C3=A4fer?= <felix@thegcat.net>
Date: Fri, 6 Nov 2020 18:24:10 +0100
Subject: [PATCH] Simplify using a non-local DB

kif/akplanning#94
---
 tasks/main.yml                   | 15 ---------------
 templates/settings_secrets.py.j2 |  2 ++
 2 files changed, 2 insertions(+), 15 deletions(-)

diff --git a/tasks/main.yml b/tasks/main.yml
index 80dc646..0fe9ef9 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -20,14 +20,6 @@
     path: /srv/AKPlanning/AKPlanning/settings_production.py
   register: akplanning_settings
 
-- name: Set the original db host so we can update # noqa 208
-  lineinfile:
-    path: /srv/AKPlanning/AKPlanning/settings_production.py
-    line: "        'HOST': 'localhost',"
-    regexp: "^        'HOST':"
-  when: akplanning_settings.stat.exists
-  notify: restart akplanning
-
 - name: Clone AKPlanning
   git:
     repo: https://gitlab.fachschaften.org/kif/akplanning.git
@@ -83,13 +75,6 @@
     group: django
   notify: restart akplanning
 
-- name: Set the correct db host # noqa 208
-  lineinfile:
-    path: /srv/AKPlanning/AKPlanning/settings_production.py
-    line: "        'HOST': '{{ hostvars[akplanning_mariadb_host]['ansible_default_ipv4']['address'] }}',"
-    regexp: "^        'HOST':"
-  notify: restart akplanning
-
 - name: AKPlanning migrate and stuff
   shell: |
     . /srv/AKPlanning/venv/bin/activate
diff --git a/templates/settings_secrets.py.j2 b/templates/settings_secrets.py.j2
index 5729275..b0e57be 100644
--- a/templates/settings_secrets.py.j2
+++ b/templates/settings_secrets.py.j2
@@ -7,3 +7,5 @@ DB_NAME = '{{ akplanning_mariadb_user }}'
 DB_USER = '{{ akplanning_mariadb_user }}'
 
 DB_PASSWORD = '{{ akplanning_mariadb_pass }}'
+
+DB_HOST = '{{ hostvars[akplanning_mariadb_host]['ansible_default_ipv4']['address'] }}'
-- 
GitLab