diff --git a/defaults/main.yml b/defaults/main.yml index e2e2f1db..b84c5cda 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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: diff --git a/releasenotes/notes/add-nova-lxd-f094438e4bf36d52.yaml b/releasenotes/notes/add-nova-lxd-f094438e4bf36d52.yaml new file mode 100644 index 00000000..6b989b92 --- /dev/null +++ b/releasenotes/notes/add-nova-lxd-f094438e4bf36d52.yaml @@ -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``. diff --git a/tasks/main.yml b/tasks/main.yml index 32ae2952..a77a65d2 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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: diff --git a/tasks/nova_compute.yml b/tasks/nova_compute.yml index 3983c776..00896cee 100644 --- a/tasks/nova_compute.yml +++ b/tasks/nova_compute.yml @@ -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 diff --git a/tasks/nova_compute_lxd.yml b/tasks/nova_compute_lxd.yml new file mode 100644 index 00000000..d3162e98 --- /dev/null +++ b/tasks/nova_compute_lxd.yml @@ -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 diff --git a/tasks/nova_compute_lxd_install.yml b/tasks/nova_compute_lxd_install.yml new file mode 100644 index 00000000..f2cafce6 --- /dev/null +++ b/tasks/nova_compute_lxd_install.yml @@ -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 diff --git a/tasks/nova_install_apt.yml b/tasks/nova_install_apt.yml index 7be76561..ec3a7474 100644 --- a/tasks/nova_install_apt.yml +++ b/tasks/nova_install_apt.yml @@ -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 diff --git a/templates/lxd-init.sh.j2 b/templates/lxd-init.sh.j2 new file mode 100644 index 00000000..e44dda84 --- /dev/null +++ b/templates/lxd-init.sh.j2 @@ -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 }} diff --git a/templates/nova.conf.j2 b/templates/nova.conf.j2 index de188653..90dcc125 100644 --- a/templates/nova.conf.j2 +++ b/templates/nova.conf.j2 @@ -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 }} diff --git a/vars/ubuntu-14.04.yml b/vars/ubuntu-14.04.yml index 2016946c..ad4eb2d4 100644 --- a/vars/ubuntu-14.04.yml +++ b/vars/ubuntu-14.04.yml @@ -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" diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml index e31edceb..992862d5 100644 --- a/vars/ubuntu-16.04.yml +++ b/vars/ubuntu-16.04.yml @@ -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 }}"