forked from evolix/ansible-roles
kvm-host: images path is customizable
This commit is contained in:
parent
a179f824f1
commit
9c797ea273
|
@ -8,4 +8,4 @@ Everything is in the `tasks/main.yml` file.
|
||||||
|
|
||||||
## Available variables
|
## Available variables
|
||||||
|
|
||||||
There is no variable.
|
* `kvm_custom_libvirt_images_path`: a custom directory for libvirt images (default: empty) ;
|
||||||
|
|
2
kvm-host/defaults/main.yml
Normal file
2
kvm-host/defaults/main.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
kvm_custom_libvirt_images_path: ''
|
|
@ -1,15 +1,38 @@
|
||||||
---
|
---
|
||||||
- name: Create images directory
|
|
||||||
|
- 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
|
||||||
|
|
||||||
|
- 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
|
||||||
|
when: kvm_custom_libvirt_images_path != ''
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- 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:
|
file:
|
||||||
path: '/home/images'
|
path: "{{ kvm_custom_libvirt_images_path }}"
|
||||||
state: directory
|
|
||||||
owner: root
|
owner: root
|
||||||
group: libvirt
|
group: libvirt
|
||||||
mode: 02775
|
mode: "02775"
|
||||||
|
|
||||||
- name: Symlink for libvirt images directory
|
- name: "Symlink {{ kvm_custom_libvirt_images_path }} to /var/lib/libvirt/images"
|
||||||
file:
|
file:
|
||||||
src: '/home/images'
|
src: "{{ kvm_custom_libvirt_images_path }}"
|
||||||
dest: '/var/lib/libvirt/images'
|
dest: '/var/lib/libvirt/images'
|
||||||
state: link
|
state: link
|
||||||
force: yes
|
when:
|
||||||
|
- 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
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## TODO: check why it's disabled
|
||||||
#- include: ssh.yml
|
#- include: ssh.yml
|
||||||
|
|
||||||
- include: packages.yml
|
- include: packages.yml
|
||||||
|
|
|
@ -3,9 +3,10 @@
|
||||||
apt:
|
apt:
|
||||||
name: "{{ item }}"
|
name: "{{ item }}"
|
||||||
with_items:
|
with_items:
|
||||||
- libvirt-bin
|
|
||||||
- qemu-kvm
|
- qemu-kvm
|
||||||
- netcat-openbsd
|
- netcat-openbsd
|
||||||
- bridge-utils
|
- bridge-utils
|
||||||
- qemu-utils
|
- qemu-utils
|
||||||
- virtinst
|
- virtinst
|
||||||
|
- libvirt-daemon-system
|
||||||
|
- libvirt-clients
|
||||||
|
|
Loading…
Reference in a new issue