writefreely/tasks/main.yaml
changeset 26 b0e4ad2f4291
parent 18 ea20908c3904
child 27 8fddefdd948b
--- a/writefreely/tasks/main.yaml	Sat May 16 09:55:46 2020 -0500
+++ b/writefreely/tasks/main.yaml	Sat May 16 10:07:24 2020 -0500
@@ -23,6 +23,7 @@
     owner: "{{writefreely_user}}"
     group: "{{writefreely_user}}"
     mode: "0755"
+  notify: migrate db
 
 - name: create root dir
   become: yes
@@ -64,12 +65,18 @@
     group: "{{writefreely_user}}"
   notify: reload service
 
+- name: check if keys exists
+  stat:
+    path: "{{writefreely_dir}}/{{writefreely_instance}}/keys/cookies_auth.aes256"
+  register: keys_file
+
 - name: generate keys
   become: yes
   become_user: "{{writefreely_user}}"
   command: "writefreely keys gen"
   args:
     chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
+  when: not key_file.stat.exists
 
 - name: check if db exists
   stat:
@@ -92,14 +99,6 @@
     chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
   when: not db_file.stat.exists
 
-- name: migrate db
-  become: yes
-  become_user: "{{writefreely_user}}"
-  command: "writefreely db migrate"
-  args:
-    chdir: "{{writefreely_dir}}/{{writefreely_instance}}/"
-  when: db_file.stat.exists
-
 - name: install systemd service
   become: yes
   template: