Wait for guest capabilities to appear

Deploying the multi-node-aio from master on a machine running Ubuntu
14.04 fails frequently as libvirt doesn't think it has the hvm
OS type.  I was able to manually run "virsh capabilities" shortly after
libvirt was installed and sure enough it didn't list any guest
capabilities.  Subsequent runs of "virsh capabilities" then returned
the <guest> XML element w/ <os_type>hvm</os_type> defined.

This commit simply adds a task that checks "virsh capabilities",
retrying up to 6 times if the <guest> element is not present.  From my
limit testing this seems sufficient to ensure that the domains are
defined and created successfully.

Lastly, we add a task to create /etc/libvirt/storage which is expected
to exist, but doesn't on a 14.04 deployment.

Change-Id: I158987270b71d3781e91d819fdcb02da736f3c1d
This commit is contained in:
Matt Thompson 2017-09-06 13:04:37 -04:00
parent cd30dba4fe
commit 815ac51249
2 changed files with 15 additions and 0 deletions

View File

@ -49,6 +49,16 @@
- hostvars[item]['server_vm'] | default(false) | bool
with_items: "{{ groups['pxe_servers'] }}"
- name: Wait for guest capabilities to appear
command: "virsh capabilities"
register: virsh_caps
until: "'<guest>' in virsh_caps.stdout"
retries: 6
delay: 10
when:
- hostvars[item]['server_vm'] | default(false) | bool
with_items: "{{ groups['pxe_servers'] }}"
- name: Define the VM
command: "virsh define /etc/libvirt/qemu/{{ hostvars[item]['server_hostname'] }}.xml"
failed_when: false

View File

@ -198,6 +198,11 @@
failed_when: false
register: virsh_data_volume
- name: Create /etc/libvirt/storage directory
file:
path: "/etc/libvirt/storage/"
state: "directory"
- name: Create virsh data volume
shell: |
virsh pool-create-as vg01 logical