ansible-xen-vm-creator/tasks/install-vms.yml

24 lines
776 B
YAML

---
- name: Set variables
changed_when: false
set_fact:
vm: "{{ xen_vm_creator_vm_defaults|combine(xen_vm_creator_vm) }}"
- name: VM that is to be installed
debug:
var: vm
- name: Check if vm needs installation
shell: >
test -x {{ xen_vm_creator_xen_config_dir }}/{{ vm.hostname }}.cfg ||
test -e {{ xen_vm_creator_xen_config_dir }}/auto/{{ vm.hostname }}.cfg ||
(lvs {{xen_vm_creator_lvm_vg_name}}/{{ vm.hostname }}-disk >/dev/null || false) ||
(lvs {{xen_vm_creator_lvm_vg_name}}/{{ vm.hostname }} >/dev/null || false)
changed_when: false
failed_when: xen_vm_creator_is_installed.rc not in [0, 1]
register: xen_vm_creator_is_installed
- name: Install vm
include: install-vm.yml
when: xen_vm_creator_is_installed.rc == 1