From d455de52b3bc31ebd578200f682521b5473cf52c Mon Sep 17 00:00:00 2001 From: Alexis Ben Miloud--Josselin Date: Thu, 3 Mar 2022 11:48:39 +0100 Subject: [PATCH] Check if /etc/libvirt/qemu/*xml exists before sync This will prevent sending e-mails saying the file does not exists. --- kvm-host/tasks/ssh.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kvm-host/tasks/ssh.yml b/kvm-host/tasks/ssh.yml index 54f69652..dfd4eda2 100644 --- a/kvm-host/tasks/ssh.yml +++ b/kvm-host/tasks/ssh.yml @@ -33,7 +33,7 @@ state: present special_time: "hourly" user: root - job: "rsync -a --delete /etc/libvirt/qemu/*xml {{ hostvars[kvm_pair]['lan.ip'] }}:/root/libvirt-{{ inventory_hostname }}/" + job: "if ! ls /etc/libvirt/qemu/*xml > /dev/null 2> /dev/null; then rsync -a --delete /etc/libvirt/qemu/*xml {{ hostvars[kvm_pair]['lan.ip'] }}:/root/libvirt-{{ inventory_hostname }}/; fi" when: - kvm_pair is defined - kvm_pair is not none