Browse Source

Merge pull request #6963 from tzumainn/image-flavor-check

Automatic merge from submit-queue.

Generic OS image/flavor check that verifies existence and compatibility

Adds playbook to check that a flavor/image pair are compatible in terms of disk/ram requirements.
OpenShift Merge Robot 7 years ago
parent
commit
c3332595ea

+ 9 - 28
roles/openshift_openstack/tasks/check-prerequisites.yml

@@ -49,16 +49,6 @@
     that: 'jinja_result.rc == 0'
     msg: "Python module jinja2 is not installed"
 
-# Check Glance image
-- name: Try to get image facts
-  os_image_facts:
-    image: "{{ openshift_openstack_default_image_name }}"
-  register: image_result
-- name: Check that image is available
-  assert:
-    that: "image_result.ansible_facts.openstack_image"
-    msg: "Image {{ openshift_openstack_default_image_name }} is not available"
-
 # Check network name
 - name: Try to get network facts
   os_networks_facts:
@@ -86,22 +76,13 @@
     that: 'key_result.rc == 0'
     msg: "Keypair {{ openshift_openstack_keypair_name }} is not available"
 
-# Check that custom images are available
-- include_tasks: custom_image_check.yaml
-  with_items:
-  - "{{ openshift_openstack_master_image }}"
-  - "{{ openshift_openstack_infra_image }}"
-  - "{{ openshift_openstack_cns_image }}"
-  - "{{ openshift_openstack_node_image }}"
-  - "{{ openshift_openstack_lb_image }}"
-  - "{{ openshift_openstack_etcd_image }}"
-
-# Check that custom flavors are available
-- include_tasks: custom_flavor_check.yaml
+# Check flavors and images
+- include_tasks: image-and-flavor-check.yml
   with_items:
-  - "{{ openshift_openstack_master_flavor }}"
-  - "{{ openshift_openstack_infra_flavor }}"
-  - "{{ openshift_openstack_cns_flavor }}"
-  - "{{ openshift_openstack_node_flavor }}"
-  - "{{ openshift_openstack_lb_flavor }}"
-  - "{{ openshift_openstack_etcd_flavor }}"
+  - { image: "{{ openshift_openstack_default_image_name }}", flavor: "{{ openshift_openstack_default_flavor }}" }
+  - { image: "{{ openshift_openstack_master_image }}", flavor: "{{ openshift_openstack_master_flavor }}" }
+  - { image: "{{ openshift_openstack_infra_image }}", flavor: "{{ openshift_openstack_infra_flavor }}" }
+  - { image: "{{ openshift_openstack_cns_image }}", flavor: "{{ openshift_openstack_cns_flavor }}" }
+  - { image: "{{ openshift_openstack_node_image }}", flavor: "{{ openshift_openstack_node_flavor }}" }
+  - { image: "{{ openshift_openstack_lb_image }}", flavor: "{{ openshift_openstack_lb_flavor }}" }
+  - { image: "{{ openshift_openstack_etcd_image }}", flavor: "{{ openshift_openstack_etcd_flavor }}" }

+ 0 - 10
roles/openshift_openstack/tasks/custom_flavor_check.yaml

@@ -1,10 +0,0 @@
----
-- name: Try to get flavor facts
-  os_flavor_facts:
-    name: "{{ item }}"
-  register: flavor_result
-
-- name: Check that custom flavor is available
-  assert:
-    that: "flavor_result.ansible_facts.openstack_flavors"
-    msg: "Flavor {{ item }} is not available."

+ 0 - 10
roles/openshift_openstack/tasks/custom_image_check.yaml

@@ -1,10 +0,0 @@
----
-- name: Try to get image facts
-  os_image_facts:
-    image: "{{ item }}"
-  register: image_result
-
-- name: Check that custom image is available
-  assert:
-    that: "image_result.ansible_facts.openstack_image"
-    msg: "Image {{ item }} is not available."

+ 27 - 0
roles/openshift_openstack/tasks/image-and-flavor-check.yml

@@ -0,0 +1,27 @@
+---
+- name: Try to get flavor facts
+  os_flavor_facts:
+    name: "{{ item.flavor }}"
+  register: flavor_result
+
+- name: Check that flavor is available
+  assert:
+    that: "flavor_result.ansible_facts.openstack_flavors"
+    msg: "Flavor {{ item.flavor }} is not available."
+
+- name: Try to get image facts
+  os_image_facts:
+    image: "{{ item.image }}"
+  register: image_result
+
+- name: Check that image is available
+  assert:
+    that: "image_result.ansible_facts.openstack_image"
+    msg: "Image {{ item.image }} is not available."
+
+- name: Verify flavor meets image requirements
+  assert:
+    that:
+    - "flavor_result.ansible_facts.openstack_flavors[0].ram >= image_result.ansible_facts.openstack_image.min_ram"
+    - "flavor_result.ansible_facts.openstack_flavors[0].disk >= image_result.ansible_facts.openstack_image.min_disk"
+    msg: "Flavor {{ item.flavor }} does not meet the size requirements for image {{ item.image }}."