From f08e84a6ed89d761c2b2ac4308314c32b23a279b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B6rg=20Sachse?= <joerg.sachse@slub-dresden.de>
Date: Fri, 20 Oct 2023 15:24:40 +0200
Subject: [PATCH] fix: remove pdfa_webservice directory before fresh deploy,
 because else Git will go on strike

---
 tasks/compile_callas_binaries.yml | 22 +++++++---------------
 1 file changed, 7 insertions(+), 15 deletions(-)

diff --git a/tasks/compile_callas_binaries.yml b/tasks/compile_callas_binaries.yml
index 45520bc..cebc842 100644
--- a/tasks/compile_callas_binaries.yml
+++ b/tasks/compile_callas_binaries.yml
@@ -23,11 +23,13 @@
     src: "{{ role_path }}/../ansible_vaults/{{ role_name }}/id_ed25519_deploykey"
     dest: "/tmp/id_ed25519_deploykey"
     mode: "0600"
-#   delegate_to: 127.0.0.1
 
-# ATTENTION:
-#   - This is run on the controller PC, not on the target! Needs Git binary.
-#   - This task requires Git credentials to be entered in interactive mode.
+- name: clear Git repo directory for fresh checkout
+  ansible.builtin.file:
+    path: "/opt/pdfa_webservice/"
+    state: absent
+  changed_when: false    # This cannot be idempotent, because later tasks change the repo content.
+
 - name: checkout PDF/A-Webservice Git repo
   ansible.builtin.git:
     repo: "git@git.slub-dresden.de:slub-digitalpreservation/pdfa_webservice.git"
@@ -36,18 +38,9 @@
     force: true
     key_file: "/tmp/id_ed25519_deploykey"
     ssh_opts: "-o StrictHostKeyChecking=accept-new"
-#   delegate_to: 127.0.0.1
+    update: true
   changed_when: false    # This cannot be idempotent, because later tasks change the repo content.
 
-# - name: copy PDF/A-Webservice Git repo to managed host
-#   ansible.builtin.copy:
-#     src: "/tmp/pdfa_webservice/"
-#     dest: "/opt/pdfa_webservice/"
-#     directory_mode: "0755"
-#     mode: "0644"
-#   register: cp_git
-#   changed_when: false    # I have no idea why this isn't idempotent.
-
 - name: set symlinks for Callas PDF Engine
   ansible.builtin.file:
     state: link
@@ -72,5 +65,4 @@
 - name: compile PDF/A-Webservice binary    # noqa command-instead-of-shell
   ansible.builtin.shell:
     cmd: 'CXXFLAGS="-std=c++11" make --directory /opt/pdfa_webservice/src/'
-#  when: cp_git.failed is false
   changed_when: false    # This always changes, because the dest path is fresh.
-- 
GitLab