Enable nested virtualization on target hosts for kolla installer
After this patch, all target hosts will have KVM nested
virtualization enabled, so they can host VMs that can
in turn host VMs.
installer-type: kolla
deploy-scenario: os-nosdn-nofeature
Change-Id: Ie430b88319a329152f17c071a8dad2564a371932
diff --git a/playbooks/roles/configure-targethosts/tasks/main.yml b/playbooks/roles/configure-targethosts/tasks/main.yml
index 3fde5ec..3a02d5f 100644
--- a/playbooks/roles/configure-targethosts/tasks/main.yml
+++ b/playbooks/roles/configure-targethosts/tasks/main.yml
@@ -21,6 +21,7 @@
- include: install-packages.yml
- include: sync-time.yml
- include: create-swap.yml
+- include: prepare-nova-kvm.yml
- include: prepare-cinder-{{ cinder_storage_driver }}.yml
- include: prepare-cinder-backup-{{ cinder_storage_backup_driver }}.yml
diff --git a/playbooks/roles/configure-targethosts/tasks/prepare-nova-kvm.yml b/playbooks/roles/configure-targethosts/tasks/prepare-nova-kvm.yml
new file mode 100644
index 0000000..daddfa0
--- /dev/null
+++ b/playbooks/roles/configure-targethosts/tasks/prepare-nova-kvm.yml
@@ -0,0 +1,66 @@
+---
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 The Nordix Foundation. All rights reserved.
+# ================================================================================
+# 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.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+- name: Get node name from IDF for host "{{ inventory_hostname }}"
+ set_fact:
+ node_name: "{{ item.key }}"
+ with_dict: "{{ idf.kolla.hostnames }}"
+ when: item.value == inventory_hostname
+
+- name: Set facts for the node "{{ node_name }}"
+ set_fact:
+ node: "{{ nodes | selectattr('name', 'equalto', node_name) | first }}"
+
+- name: Setup nested virtualization for Debian hosts
+ lineinfile:
+ path: "/etc/modprobe.d/qemu-system-x86.conf"
+ regexp: "^options kvm_intel nested=.*"
+ line: "options kvm_intel nested=1"
+ create: true
+ when:
+ - ansible_os_family == 'Debian'
+ - node.node.type == 'baremetal'
+
+- name: Setup nested virtualization for RedHat hosts
+ lineinfile:
+ path: "/etc/modprobe.d/kvm-nested.conf"
+ regexp: "^options kvm_intel nested=.*"
+ line: "options kvm_intel nested=1"
+ create: true
+ when:
+ - ansible_os_family == 'RedHat'
+ - node.node.type == 'baremetal'
+
+- name: Reboot the machine
+ shell: "sleep 5 && reboot"
+ async: 1
+ poll: 0
+ changed_when: false
+
+- name: Wait for host to come back to life
+ wait_for_connection:
+ connect_timeout: 10
+ sleep: 5
+ delay: 120
+ timeout: 300
+ register: result
+ until: result | succeeded
+ retries: 3
+
+# vim: set ts=2 sw=2 expandtab: