]> git.phdru.name Git - ansible.git/blobdiff - playbooks/debian/sa-merge-all.yml
Feat(sa-merge-all): Use `sa-merge-all.py` to merge dumps; use `chdir`
[ansible.git] / playbooks / debian / sa-merge-all.yml
index 7c35a9331ee76271891886d7248982ea976bb547..dbf9b4c1b00b093a40d96053f74e7a4c222d0d47 100644 (file)
@@ -15,7 +15,7 @@
           state: stopped
 
       - name: Backup SpamAssassin DB
-        shell: "exec sa-learn --backup >~/tmp/sa-learn.backup@{{ inventory_hostname }}"
+        shell: "sa-learn --sync && exec sa-learn --backup >~/tmp/sa-learn.backup@{{ inventory_hostname }}"
       - name: Fetch SpamAssassin DB backup
         synchronize:
           src: "~/tmp/sa-learn.backup@{{ inventory_hostname }}"
@@ -24,7 +24,9 @@
       when: inventory_hostname != 'localhost'
 
     - name: Combine SpamAssassin DB backups
-      shell: "cd ~/tmp && exec cat sa-learn.backup.* >sa-learn.backup"
+      shell: "exec {{ playbook_dir }}/sa-merge-all.py -o sa-learn.backup sa-learn.backup@*"
+      args:
+        chdir: "~/tmp"
       when: inventory_hostname == 'localhost'
 
     - block:
         synchronize:
           src: "~/tmp/sa-learn.backup"
           dest: "~/tmp/sa-learn.backup"
-      - name: Combine SpamAssassin DB backups
-        shell: "cd tmp && sa-learn --clear && sa-learn --restore sa-learn.backup && exec sa-learn --sync"
+      - name: Restore combined SpamAssassin DB
+        shell: "sa-learn --clear && sa-learn --restore sa-learn.backup && exec sa-learn --sync"
+        args:
+          chdir: "~/tmp"
 
       - name: Start SpamAssassin
         become: true
@@ -48,4 +52,6 @@
       when: inventory_hostname != 'localhost'
 
     - name: Cleanup
-      shell: "cd ~/tmp && exec rm sa-learn.backup*"
+      shell: "exec rm sa-learn.backup*"
+      args:
+        chdir: "~/tmp"