openqa/server: only do createhdds when images are missing

I've enhanced `createhdds check` to exit 1 if all images are
present but some are old, and 2 if any images are missing. We
use this to only create images if any are missing here in the
play; we rely on the daily cron job to rebuild old images.

This is kind of a band-aid for a weird issue on openqa01 where
virt-install runs just don't seem to work properly after the
box has been running for a while, so createhdds doesn't actually
work and any playbook run gets hung up on it for a long time.
This doesn't fix that, but does at least mean we can run the
playbook without being bothered by it. To get createhdds to run
properly and actually regenerate the outdated images, we have
to reboot the system and run it right away, it seems to work
fine right after the system boots up.
This commit is contained in:
Adam Williamson 2016-10-17 11:39:14 -07:00
parent 7cf4f3f2be
commit a5894c93be

View file

@ -145,16 +145,15 @@
- name: Ensure libvirt is running if needed to create images
service: name=libvirtd enabled=yes state=started
when: "diskcheck.rc > 0"
when: "diskcheck.rc > 1"
# createhdds is kinda fragile and failure is not really fatal on an
# existing deployment (just means we have an outdated disk image), so
# we ignore_errors so the rest of the playbook will complete even if
# it fails
# > 1 is not a typo; check exits with 1 if all images are present but some
# are outdated, and 2 if any images are missing. We only want to handle
# outright *missing* images here in the playbook (to handle the case of
# first deployment). Outdated images are handled by the daily cron run.
- name: Create hard disk images (this may take a long time!)
command: "/etc/cron.daily/createhdds"
when: "diskcheck.rc > 0"
ignore_errors: yes
when: "diskcheck.rc > 1"
- name: Create exports file
copy: src=exports dest=/etc/exports.d/openqa.exports owner=root group=root mode=0644