From 79192de31000b73f911890fd505ab9b64fbc864d Mon Sep 17 00:00:00 2001 From: Jesse Pretorius Date: Wed, 2 Dec 2015 14:40:47 +0000 Subject: [PATCH] Fix nova_virt_type auto-detection In https://review.openstack.org/243098 nova_virt_type auto-detection was implemented, but the default nova_virt_type value of kvm was left in place, resulting in the auto-detection never happening. This patch implements the auto-detection if nova-virt_type is not set and removes the default value for nova-virt_type. Change-Id: Ic1c8f042bc6bbee542373d335f338866efa06dc7 --- defaults/main.yml | 9 ++------- tasks/main.yml | 5 +++++ tasks/nova_compute.yml | 2 +- tasks/nova_post_install.yml | 19 ------------------- tasks/nova_virt_detect.yml | 29 +++++++++++++++++++++++++++++ 5 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 tasks/nova_virt_detect.yml diff --git a/defaults/main.yml b/defaults/main.yml index d2579983..1c57985b 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -60,15 +60,10 @@ nova_rpc_thread_pool_size: 64 nova_rpc_conn_pool_size: 30 nova_rpc_response_timeout: 60 -## Nova virtualization Type Autodetect -# Set to True if nova_virt_type is not defined, then it will auto -# choose kvm or qemu for nova_virt_type according to /proc/cpuinfo -nova_virt_autodetect: True - ## Nova virtualization Type, set to KVM if supported # Current supported choice: qemu or kvm -# Once nova_virt_type is defined, then nova_virt_autodetect won't work any more -nova_virt_type: kvm +# If this is not set, then the playbook will try to guess it. +#nova_virt_type: kvm ## Nova Auth nova_service_region: RegionOne diff --git a/tasks/main.yml b/tasks/main.yml index 194f6b5c..b647d07f 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -13,6 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +- include: nova_virt_detect.yml + when: nova_virt_type is not defined + tags: + nova-virt-detect + - include: nova_pre_install.yml - include: nova_install.yml - include: nova_console_install.yml diff --git a/tasks/nova_compute.yml b/tasks/nova_compute.yml index 5a1198a7..70da214f 100644 --- a/tasks/nova_compute.yml +++ b/tasks/nova_compute.yml @@ -14,7 +14,7 @@ # limitations under the License. - include: nova_compute_kvm.yml - when: nova_virt_type == 'kvm' or nova_virt_type == 'qemu' or nova_virt_autodetect | bool + when: nova_virt_type == 'kvm' or nova_virt_type == 'qemu' - include: nova_compute_key_populate.yml diff --git a/tasks/nova_post_install.yml b/tasks/nova_post_install.yml index b6f55d58..37ef3d87 100644 --- a/tasks/nova_post_install.yml +++ b/tasks/nova_post_install.yml @@ -13,25 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Get virt type value and store as var - shell: | - /usr/bin/egrep -c '(vmx|svm)' /proc/cpuinfo - register: virt_type_value - changed_when: false - failed_when: false - when: nova_virt_type != 'kvm' and nova_virt_type != 'qemu' and nova_virt_autodetect | bool - tags: - - nova-config - - nova-post-install - -- name: Register a fact for the nova virt type - set_fact: - nova_virt_type: "{{ ((virt_type_value.stdout | int) > 0) | ternary('kvm', 'qemu') }}" - when: nova_virt_type != 'kvm' and nova_virt_type != 'qemu' and nova_virt_autodetect | bool - tags: - - nova-config - - nova-post-install - - name: Copy nova config config_template: src: "{{ item.src }}" diff --git a/tasks/nova_virt_detect.yml b/tasks/nova_virt_detect.yml new file mode 100644 index 00000000..238ff193 --- /dev/null +++ b/tasks/nova_virt_detect.yml @@ -0,0 +1,29 @@ +--- +# Copyright 2014, Rackspace US, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Get virt type value and store as var + shell: | + /usr/bin/egrep -c '(vmx|svm)' /proc/cpuinfo + register: virt_type_value + changed_when: false + failed_when: false + tags: + - nova-cpuinfo-read + +- name: Register a fact for the nova virt type + set_fact: + nova_virt_type: "{{ ((virt_type_value.stdout | int) > 0) | ternary('kvm', 'qemu') }}" + tags: + - nova-virt-type-set