Change variable item by kvm_pair and disable loop on all 'hypervisor' group
continuous-integration/drone/push Build is failing Details

This commit is contained in:
Eric Morino 2021-11-26 11:08:02 +01:00
parent 53cd3ba342
commit 2ec026c2b3
1 changed files with 6 additions and 8 deletions

View File

@ -29,22 +29,20 @@
- name: Crontab for sync libvirt xml file
cron:
name: "sync libvirt xml on {{ item }}"
name: "sync libvirt xml on {{ kvm_pair }}"
state: present
special_time: "hourly"
user: root
job: "rsync -a --delete /etc/libvirt/qemu/*xml {{ hostvars[item]['ansible_pair'] }}:/root/libvirt-{{ inventory_hostname }}/"
loop: "{{ groups['hypervisors'] }}"
when: item != inventory_hostname
job: "rsync -a --delete /etc/libvirt/qemu/*xml {{ hostvars[kvm_pair]['lan.ip'] }}:/root/libvirt-{{ inventory_hostname }}/"
when: kvm_pair != inventory_hostname
tags: crontab
- name: Crontab for sync list of running vm
cron:
name: "sync list of libvirt running vm on {{ item }}"
name: "sync list of libvirt running vm on {{ kvm_pair }}"
state: present
special_time: "daily"
user: root
job: "virsh list --all | tee /root/virsh-list.txt | ssh {{ hostvars[item]['ansible_pair'] }} 'cat >/root/libvirt-{{ inventory_hostname }}/virsh-list.txt'"
loop: "{{ groups['hypervisors'] }}"
when: item != inventory_hostname
job: "virsh list --all | tee /root/virsh-list.txt | ssh {{ hostvars[kvm_pair]['lan.ip'] }} 'cat >/root/libvirt-{{ inventory_hostname }}/virsh-list.txt'"
when: kvm_pair != inventory_hostname
tags: crontab