Implement nova-lxd driver

This patch set is designed to allow deployers to select
the virt_type = 'lxc', which will deploy the nova-lxd
driver instead of the usual kvm driver.

Change-Id: I8b298080faaef9da1ab0040de437086a1a393296
This commit is contained in:
Michael Gugino 2016-07-14 11:59:57 -04:00
parent 106ca720d6
commit 06081df5ab
11 changed files with 183 additions and 3 deletions

View File

@ -27,9 +27,16 @@ nova_git_repo: https://git.openstack.org/openstack/nova
nova_git_install_branch: master
nova_requirements_git_repo: https://git.openstack.org/openstack/requirements
nova_requirements_git_install_branch: master
nova_lxd_git_repo: https://git.openstack.org/openstack/nova-lxd
nova_lxd_git_install_branch: master
nova_lxd_requirements_git_repo: https://git.openstack.org/openstack/requirements
nova_lxd_requirements_git_install_branch: master
nova_developer_mode: false
nova_developer_constraints:
- "git+{{ nova_git_repo }}@{{ nova_git_install_branch }}#egg=nova"
- "git+{{ nova_lxd_git_repo }}@{{ nova_lxd_git_install_branch }}#egg=nova-lxd"
# Name of the virtual env to deploy into
nova_venv_tag: untagged
@ -118,6 +125,14 @@ nova_virt_types:
nova_firewall_driver: nova.virt.firewall.NoopFirewallDriver
nova_scheduler_use_baremetal_filters: False
nova_scheduler_tracks_instance_changes: True
lxc:
nova_compute_driver: lxd.LXDDriver
nova_scheduler_host_manager: host_manager
nova_reserved_host_memory_mb: 2048
nova_compute_manager: nova.compute.manager.ComputeManager
nova_firewall_driver: nova.virt.firewall.NoopFirewallDriver
nova_scheduler_use_baremetal_filters: False
nova_scheduler_tracks_instance_changes: True
qemu:
nova_compute_driver: libvirt.LibvirtDriver
nova_scheduler_host_manager: host_manager
@ -133,10 +148,18 @@ nova_virt_types:
nova_scheduler_use_baremetal_filters: False
nova_scheduler_tracks_instance_changes: True
# Current supported choice: qemu or kvm or ironic or powervm
# If this is not set, then the playbook will try to guess it.
#nova_virt_type: kvm
#if set, nova_virt_type must be one of these:
nova_supported_virt_types:
- qemu
- kvm
- lxc
- ironic
- powervm
## Nova Auth
nova_service_region: RegionOne
nova_service_project_name: "service"
@ -380,6 +403,10 @@ nova_pip_packages:
- keystonemiddleware
- nova
nova_compute_lxd_pip_packages:
- pylxd
- nova-lxd
nova_qemu_user: libvirt-qemu
nova_qemu_group: kvm
@ -391,3 +418,9 @@ nova_policy_overrides: {}
nova_compute_powervm_pip_packages:
- nova-powervm
lxd_bind_address: 0.0.0.0
lxd_bind_port: 8443
lxd_storage_backend: dir
# This needs to be set in the user_secrets.yml file.
#lxd_trust_password:

View File

@ -0,0 +1,6 @@
---
features:
- The os_nova role can now deploy the nova-lxd hypervisor.
This can be achieved by setting ``nova_virt_type`` to
``lxc`` on a per-host basis in ``openstack_user_config.yml``
or on a global basis in ``user_variables.yml``.

View File

@ -37,6 +37,13 @@
tags:
- always
- fail: msg="Unsupported Virt Type Provided {{ nova_supported_virt_types }}"
when:
- nova_virt_type is defined
- nova_virt_type not in nova_supported_virt_types
tags:
- always
- include: nova_virt_detect.yml
when: nova_virt_type is not defined
tags:

View File

@ -19,6 +19,9 @@
- include: nova_compute_powervm.yml
when: nova_virt_type == 'powervm'
- include: nova_compute_lxd.yml
when: nova_virt_type == 'lxc'
- include: nova_compute_key_populate.yml
- include: nova_compute_key_distribute.yml

View File

@ -0,0 +1,41 @@
---
# Copyright 2016, Walmart Stores, 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.
- include: nova_compute_lxd_install.yml
- name: Add nova user to lxd group
user:
name: "{{ nova_system_user_name }}"
groups: "lxd"
append: "yes"
tags:
- nova-lxd
- name: Place lxd config script
template:
src: lxd-init.sh.j2
dest: "{{ nova_system_home_folder }}/lxd-init.sh"
owner: "{{ nova_system_user_name }}"
group: "lxd"
mode: 0770
register: lxd_init_script
tags:
- nova-lxd
- name: Configure lxd init
command: "{{ nova_system_home_folder }}/lxd-init.sh"
when: lxd_init_script | changed
tags:
- nova-lxd

View File

@ -0,0 +1,29 @@
---
# Copyright 2016, Walmart Stores, 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: Install pip packages (venv)
pip:
name: "{{ nova_compute_lxd_pip_packages | join(' ') }}"
state: latest
virtualenv: "{{ nova_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: "{{ pip_install_options_fact|default('') }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
tags:
- nova-install
- nova-pip-packages

View File

@ -115,3 +115,20 @@
tags:
- nova-apt-packages
- nova-compute-kvm-apt-packages
- name: Install apt packages (compute - LXD)
apt:
pkg: "{{ item }}"
state: "{{ nova_package_state }}"
default_release: "{{ lxd_default_release | default(omit) }}"
register: install_packages
until: install_packages|success
retries: 5
delay: 2
with_items: "{{ nova_compute_lxd_packages }}"
when:
- inventory_hostname in groups['nova_compute']
- nova_virt_type == 'lxc'
tags:
- nova-apt-packages
- nova-compute-lxd-apt-packages

12
templates/lxd-init.sh.j2 Normal file
View File

@ -0,0 +1,12 @@
#!/bin/bash
# {{ ansible_managed }}
# This is a script to configure lxd system settings.
# "/usr/bin/lxd init"
/usr/bin/lxd init \
--auto \
--network-address={{ lxd_bind_address }} \
--network-port={{ lxd_bind_port }} \
--storage-backend={{ lxd_storage_backend }} \
--trust-password={{ lxd_trust_password }}

View File

@ -103,7 +103,7 @@ auth_strategy = keystone
## Vif
linuxnet_interface_driver = {{ nova_linuxnet_interface_driver }}
{% if nova_virt_type in ['kvm', 'qemu', 'xen'] %}
{% if nova_virt_type in ['kvm', 'lxc', 'qemu', 'xen'] %}
libvirt_vif_type = ethernet
{% endif %}
vif_plugging_timeout = 10
@ -256,7 +256,7 @@ admin_url = {{ keystone_service_adminuri }}/v2.0
api_endpoint = {{ ironic_service_adminurl }}
{% endif %}
{% if nova_virt_type in ['kvm', 'qemu', 'xen'] %}
{% if nova_virt_type in ['kvm', 'lxc', 'qemu', 'xen'] %}
[libvirt]
inject_partition = {{ nova_libvirt_inject_partition }}
inject_password = {{ nova_libvirt_inject_password }}

View File

@ -52,6 +52,20 @@ nova_compute_kvm_packages:
- dosfstools-dbg
- multipath-tools
nova_compute_lxd_packages:
- bridge-utils
- dosfstools
- dosfstools-dbg
- genisoimage
- kpartx
- lxd
- multipath-tools
- nfs-common
- open-iscsi
- python-libguestfs
- sysfsutils
- vlan
# Ubuntu Cloud Archive variables
# There are no UCA packages for Trusty beyond Mitaka, so the selected
# release here has to remain at Mitaka.
@ -81,3 +95,6 @@ novalink_repo:
novalink_gpg_keys:
- url: "ftp://public.dhe.ibm.com/systems/virtualization/Novalink/debian/novalink-gpg-pub.key"
state: "present"
#lxd-specific variables
lxd_default_release: "trusty-backports"

View File

@ -52,6 +52,21 @@ nova_compute_kvm_packages:
- dosfstools-dbg
- multipath-tools
nova_compute_lxd_packages:
- bridge-utils
- dosfstools
- dosfstools-dbg
- genisoimage
- kpartx
- lxd
- multipath-tools
- nfs-common
- open-iscsi
- python-libguestfs
- sysfsutils
- vlan
# Ubuntu Cloud Archive variables
uca_openstack_release: newton
uca_repo_dist: "{{ ansible_lsb.codename }}-updates/{{ uca_openstack_release }}"