image-and-flavor-check.yml 934 B

123456789101112131415161718192021222324252627
  1. ---
  2. - name: Try to get flavor facts
  3. os_flavor_facts:
  4. name: "{{ item.flavor }}"
  5. register: flavor_result
  6. - name: Check that flavor is available
  7. assert:
  8. that: "flavor_result.ansible_facts.openstack_flavors"
  9. msg: "Flavor {{ item.flavor }} is not available."
  10. - name: Try to get image facts
  11. os_image_facts:
  12. image: "{{ item.image }}"
  13. register: image_result
  14. - name: Check that image is available
  15. assert:
  16. that: "image_result.ansible_facts.openstack_image"
  17. msg: "Image {{ item.image }} is not available."
  18. - name: Verify flavor meets image requirements
  19. assert:
  20. that:
  21. - "flavor_result.ansible_facts.openstack_flavors[0].ram >= image_result.ansible_facts.openstack_image.min_ram"
  22. - "flavor_result.ansible_facts.openstack_flavors[0].disk >= image_result.ansible_facts.openstack_image.min_disk"
  23. msg: "Flavor {{ item.flavor }} does not meet the size requirements for image {{ item.image }}."