2017-02-16 14:52:35 +01:00
|
|
|
---
|
2017-07-19 01:34:13 +02:00
|
|
|
|
2019-12-31 16:56:03 +01:00
|
|
|
- name: Set images path when customized
|
|
|
|
block:
|
|
|
|
- name: "Is {{ kvm_custom_libvirt_images_path }} present ?"
|
|
|
|
stat:
|
|
|
|
path: "{{ kvm_custom_libvirt_images_path }}"
|
|
|
|
check_mode: no
|
|
|
|
register: kvm_custom_libvirt_images_path_test
|
2017-07-19 01:34:13 +02:00
|
|
|
|
2019-12-31 16:56:03 +01:00
|
|
|
- name: "read the real datadir"
|
|
|
|
command: readlink -f /var/lib/libvirt/images
|
|
|
|
changed_when: False
|
|
|
|
check_mode: no
|
|
|
|
register: kvm_libvirt_images_current_real_path_test
|
2017-07-19 01:34:13 +02:00
|
|
|
when: kvm_custom_libvirt_images_path != ''
|
|
|
|
|
2019-12-31 16:56:03 +01:00
|
|
|
- name: Images directory is moved to custom path
|
|
|
|
block:
|
2017-07-19 01:34:13 +02:00
|
|
|
- name: "Move libvirt images to {{ kvm_custom_libvirt_images_path }}"
|
|
|
|
command: mv /var/lib/libvirt/images {{ kvm_custom_libvirt_images_path }}
|
|
|
|
args:
|
|
|
|
creates: "{{ kvm_custom_libvirt_images_path }}"
|
|
|
|
|
|
|
|
- name: Fix owner/group/permissions
|
|
|
|
file:
|
|
|
|
path: "{{ kvm_custom_libvirt_images_path }}"
|
|
|
|
owner: root
|
|
|
|
group: libvirt
|
|
|
|
mode: "02775"
|
|
|
|
|
|
|
|
- name: "Symlink {{ kvm_custom_libvirt_images_path }} to /var/lib/libvirt/images"
|
|
|
|
file:
|
|
|
|
src: "{{ kvm_custom_libvirt_images_path }}"
|
|
|
|
dest: '/var/lib/libvirt/images'
|
|
|
|
state: link
|
|
|
|
when:
|
2019-12-31 16:56:03 +01:00
|
|
|
- kvm_custom_libvirt_images_path != ''
|
|
|
|
- kvm_custom_libvirt_images_path != kvm_libvirt_images_current_real_path_test.stdout
|
|
|
|
- not kvm_custom_libvirt_images_path_test.stat.exists
|