25 lines
570 B
YAML
25 lines
570 B
YAML
|
---
|
||
|
|
||
|
- name: find already defined local VMs
|
||
|
virt: command=list_vms
|
||
|
delegate_to: 127.0.0.1 # local action
|
||
|
# become: True
|
||
|
register: vms
|
||
|
|
||
|
- block:
|
||
|
- name: construct VM xml file
|
||
|
template:
|
||
|
src: templates/loctevm.xml
|
||
|
dest: "{{ vm_path }}/loctevm.xml"
|
||
|
delegate_to: 127.0.0.1 # local action
|
||
|
|
||
|
- name: define VM
|
||
|
virt:
|
||
|
command: define
|
||
|
name: "{{ inventory_hostname }}"
|
||
|
xml: "{{ lookup('file',vm_path ~ '/loctevm.xml') }}"
|
||
|
delegate_to: 127.0.0.1 # local action
|
||
|
|
||
|
when: not inventory_hostname in vms.list_vms
|
||
|
# block end
|