Ansible: virt module XML error -
i'm trying define vm using virt module , xml file. task:
- name: define vm using xml file virt: command=define name={{ new_vm_name }} xml={{ vm_images_path }}/{{ new_vm_xml }} remote_user: root delegate_to: "{{ hyperv }}"
fails error:
failed: [vm-002 -> nat] => {"failed": true} msg: (domain_definition):1: start tag expected, '<' not found /var/lib/libvirt/images//vm-002-ver1.1.0-00042.xml
while works:
- name: define vm using xml file command: virsh define {{ vm_images_path }}/{{ new_vm_xml }} remote_user: root delegate_to: "{{ hyperv }}"
xml file same in both cases, idea of why first 1 fails? prefer using modules custom commands i'd make first 1 work.
the xml
parameter of virt
module takes xml string, not filename.
you achieve want this:
- name: define vm using xml file virt: command=define name={{ new_vm_name }} xml={{ lookup('template', './libvirt_create_template.j2') }} remote_user: root delegate_to: "{{ hyperv }}"
the file reference in lookup located on ansible control server (i.e. run playbooks).
by using template lookup, can have vm specific settings replaces values inventory vm installing.
Comments
Post a Comment