Prechádzať zdrojové kódy

Wiki is now synced through a systemd timer and not a post receive hook any more. The post receive hook wand't documented anywhere and caused severe permission based problems

Till Klocke 7 rokov pred
rodič
commit
0b7b0badfc

+ 1 - 1
roles/service-wiki/files/post-commit

@@ -1,3 +1,3 @@
 #!/bin/bash
 
-git push origin master
+git pull origin master && git push origin master

+ 18 - 0
roles/service-wiki/tasks/main.yml

@@ -99,6 +99,24 @@
     - post-commit
     - post-update
 
+- name: Create systemd units for wiki updates
+  template:
+    src: sync_wiki.{{ item }}.j2
+    dest: /etc/systemd/system/sync_wiki.{{ item }}
+  with_items:
+  - "service"
+  - "timer"
+
+- name: Reload systemd units
+  systemd:
+    daemon_reload: yes
+    name: sync_wiki.{{ item }}
+    enabled: yes
+    state: started
+  with_items:
+  - "service"
+  - "timer"
+
 # TODO restore user data
 
 - name: Let acmetool generate a key and a certificate

+ 9 - 0
roles/service-wiki/templates/sync_wiki.service.j2

@@ -0,0 +1,9 @@
+[Unit]
+Description=Sync Wiki data with Gogs
+
+[Service]
+Type=oneshot
+WorkingDirectory={{ gitit_data_dir }}/wikidata
+ExecStart=/usr/bin/git pull origin master 
+User={{ gitit_user }}
+Group={{ gitit_group }}

+ 9 - 0
roles/service-wiki/templates/sync_wiki.timer.j2

@@ -0,0 +1,9 @@
+[Unit]
+Description=Sync Wiki data with Gogs every minute
+
+[Timer]
+OnBootSec=5min
+OnUnitInactiveSec=1min
+
+[Install]
+WantedBy=timers.target