From 1deb3b5a26d9983fdf11ef12b414bbe24c580ea5 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Wed, 9 May 2018 15:31:57 +0100 Subject: [PATCH] Add support for using distribution packages for OpenStack services Distributions provide packages for the OpenStack services so we add support for using these instead of the pip ones. Depends-On: https://review.openstack.org/#/c/579151/ Depends-On: https://review.openstack.org/#/c/579071/ Change-Id: Iff373b5402c664206b940b8e95a0b8845050213b Implements: blueprint openstack-distribution-packages --- defaults/main.yml | 20 +-- ...istribution-packages-fcb6220fdeb3668c.yaml | 7 + tasks/drivers/ironic/nova_compute_ironic.yml | 20 +-- .../ironic/nova_compute_ironic_source.yml | 32 ++++ .../drivers/kvm/nova_compute_kvm_install.yml | 51 +----- .../kvm/nova_compute_kvm_install_source.yml | 63 +++++++ tasks/drivers/lxd/nova_compute_lxd.yml | 19 +- tasks/drivers/lxd/nova_compute_lxd_source.yml | 31 ++++ tasks/main.yml | 15 ++ tasks/nova_install.yml | 166 +++--------------- tasks/nova_install_source.yml | 156 ++++++++++++++++ templates/nova-uwsgi.ini.j2 | 2 + tox.ini | 6 + vars/distro_install.yml | 54 ++++++ vars/main.yml | 31 ---- vars/redhat-7.yml | 38 +++- vars/source_install.yml | 49 ++++++ vars/suse-42.yml | 39 +++- vars/ubuntu-16.04.yml | 38 +++- zuul.d/project.yaml | 7 + 20 files changed, 576 insertions(+), 268 deletions(-) create mode 100644 releasenotes/notes/openstack-distribution-packages-fcb6220fdeb3668c.yaml create mode 100644 tasks/drivers/ironic/nova_compute_ironic_source.yml create mode 100644 tasks/drivers/kvm/nova_compute_kvm_install_source.yml create mode 100644 tasks/drivers/lxd/nova_compute_lxd_source.yml create mode 100644 tasks/nova_install_source.yml create mode 100644 vars/distro_install.yml create mode 100644 vars/source_install.yml diff --git a/defaults/main.yml b/defaults/main.yml index 7f4045d9..90215753 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -31,6 +31,9 @@ debug: False nova_package_state: "latest" nova_pip_package_state: "latest" +# Set installation method. +nova_install_method: "source" + nova_git_repo: https://git.openstack.org/openstack/nova nova_git_install_branch: master @@ -44,7 +47,7 @@ nova_developer_constraints: # Name of the virtual env to deploy into nova_venv_tag: untagged -nova_bin: "/openstack/venvs/nova-{{ nova_venv_tag }}/bin" +nova_bin: "{{ _nova_bin }}" # venv_download, even when true, will use the fallback method of building the # venv from scratch if the venv download fails. @@ -440,8 +443,8 @@ nova_services: service_name: nova-api-metadata init_config_overrides: "{{ nova_api_metadata_init_overrides }}" start_order: 5 - execstarts: "{{ nova_bin }}/uwsgi --autoload --ini /etc/uwsgi/nova-api-metadata.ini" - execreloads: "{{ nova_bin }}/uwsgi --reload /var/run/nova-api-metadata/nova-api-metadata.pid" + execstarts: "{{ nova_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/nova-api-metadata.ini" + execreloads: "{{ nova_uwsgi_bin }}/uwsgi --reload /var/run/nova-api-metadata/nova-api-metadata.pid" wsgi_app: True wsgi_overrides: "{{ nova_api_metadata_uwsgi_ini_overrides }}" uwsgi_port: "{{ nova_metadata_port }}" @@ -451,8 +454,8 @@ nova_services: service_name: nova-api-os-compute init_config_overrides: "{{ nova_api_os_compute_init_overrides }}" start_order: 4 - execstarts: "{{ nova_bin }}/uwsgi --autoload --ini /etc/uwsgi/nova-api-os-compute.ini" - execreloads: "{{ nova_bin }}/uwsgi --reload /var/run/nova-api-os-compute/nova-api-os-compute.pid" + execstarts: "{{ nova_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/nova-api-os-compute.ini" + execreloads: "{{ nova_uwsgi_bin }}/uwsgi --reload /var/run/nova-api-os-compute/nova-api-os-compute.pid" wsgi_app: True wsgi_overrides: "{{ nova_api_os_compute_uwsgi_ini_overrides }}" uwsgi_port: "{{ nova_service_port }}" @@ -504,8 +507,8 @@ nova_services: init_config_overrides: "{{ nova_placement_api_init_overrides }}" condition: "{{ nova_placement_service_enabled | bool }}" start_order: 1 - execstarts: "{{ nova_bin }}/uwsgi --autoload --ini /etc/uwsgi/nova-placement-api.ini" - execreloads: "{{ nova_bin }}/uwsgi --reload /var/run/nova-placement-api/nova-placement-api.pid" + execstarts: "{{ nova_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/nova-placement-api.ini" + execreloads: "{{ nova_uwsgi_bin }}/uwsgi --reload /var/run/nova-placement-api/nova-placement-api.pid" wsgi_app: True uwsgi_port: "{{ nova_placement_service_port }}" wsgi_name: nova-placement-api @@ -524,9 +527,6 @@ nova_novnc_pip_packages: # nova packages that must be installed before anything else nova_requires_pip_packages: - virtualenv - - python-keystoneclient # Keystoneclient needed to OSA keystone lib - - httplib2 - - python-openstackclient nova_compute_ironic_pip_packages: - python-ironicclient diff --git a/releasenotes/notes/openstack-distribution-packages-fcb6220fdeb3668c.yaml b/releasenotes/notes/openstack-distribution-packages-fcb6220fdeb3668c.yaml new file mode 100644 index 00000000..dca0d734 --- /dev/null +++ b/releasenotes/notes/openstack-distribution-packages-fcb6220fdeb3668c.yaml @@ -0,0 +1,7 @@ +--- +features: + - | + The role now supports using the distribution packages for the OpenStack + services instead of the pip ones. This feature is disabled by default + and can be enabled by simply setting the ``nova_install_method`` + variable to ``distro``. diff --git a/tasks/drivers/ironic/nova_compute_ironic.yml b/tasks/drivers/ironic/nova_compute_ironic.yml index 95b9d3f2..9b9dfc75 100644 --- a/tasks/drivers/ironic/nova_compute_ironic.yml +++ b/tasks/drivers/ironic/nova_compute_ironic.yml @@ -13,20 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -- name: Install pip packages (venv) - pip: - name: "{{ nova_compute_ironic_pip_packages }}" - state: "{{ nova_pip_package_state }}" - virtualenv: "{{ nova_bin | dirname }}" - virtualenv_site_packages: "no" - extra_args: >- - {{ nova_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} - {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} - {{ pip_install_options | default('') }} - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - tags: - - nova-install - - nova-pip-packages +- name: Install nova ironic packages from PIP + include_tasks: nova_compute_ironic_source.yml + when: nova_install_method == 'source' diff --git a/tasks/drivers/ironic/nova_compute_ironic_source.yml b/tasks/drivers/ironic/nova_compute_ironic_source.yml new file mode 100644 index 00000000..8b80a245 --- /dev/null +++ b/tasks/drivers/ironic/nova_compute_ironic_source.yml @@ -0,0 +1,32 @@ +--- +# Copyright 2018, SUSE Linux GmbH. +# +# 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_ironic_pip_packages }}" + state: "{{ nova_pip_package_state }}" + virtualenv: "{{ nova_bin | dirname }}" + virtualenv_site_packages: "no" + extra_args: >- + {{ nova_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} + {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} + {{ pip_install_options | default('') }} + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + tags: + - nova-install + - nova-pip-packages diff --git a/tasks/drivers/kvm/nova_compute_kvm_install.yml b/tasks/drivers/kvm/nova_compute_kvm_install.yml index 72a68253..14fe7978 100644 --- a/tasks/drivers/kvm/nova_compute_kvm_install.yml +++ b/tasks/drivers/kvm/nova_compute_kvm_install.yml @@ -55,51 +55,6 @@ owner: "{{ nova_qemu_user }}" group: "{{ nova_qemu_group }}" -# Note (odyssey4me): -# These python libraries have C bindings which tend to be very -# particular about the version of their companion packages. -# To ensure things run smoothly for stable releases, we opt to -# use the distro packages for these and symlink the appropriate -# library files and binding into the venv. - -- name: Link guestfs into the venv - file: - src: "{{ linkfiles.name }}" - dest: "{{ nova_bin | dirname }}/lib/python2.7/{{ linkfiles.name | basename }}" - state: "{{ linkfiles.state }}" - force: "yes" - with_items: - - { state: link, name: "/usr/lib/python2.7/dist-packages/libguestfsmod.so" } - - { state: link, name: "/usr/lib/python2.7/dist-packages/guestfs.py" } - loop_control: - loop_var: linkfiles - tags: - - nova-pip-packages - -- name: Register libvirt module path - command: python -c 'import libvirt; print libvirt.__file__' - changed_when: false - register: _libvirt_module_path - tags: - - nova-pip-packages - -- name: Register libvirt-python files - shell: >- - {{ (ansible_pkg_mgr == 'apt') | ternary('dpkg -L python-libvirt', 'rpm -ql libvirt-python') }} - | grep '^{{ _libvirt_module_path.stdout | dirname }}/' - args: - warn: no - changed_when: false - register: _libvirt_python_files - tags: - - nova-pip-packages - -- name: Link the libvirt files into venv - file: - src: "{{ item }}" - dest: "{{ nova_bin | dirname }}/lib/python2.7/site-packages/{{ item | basename }}" - state: link - force: yes - with_items: "{{ _libvirt_python_files.stdout_lines }}" - tags: - - nova-pip-packages +- name: Install nova kvm packages from PIP + include_tasks: nova_compute_kvm_install_source.yml + when: nova_install_method == 'source' diff --git a/tasks/drivers/kvm/nova_compute_kvm_install_source.yml b/tasks/drivers/kvm/nova_compute_kvm_install_source.yml new file mode 100644 index 00000000..eb708ed8 --- /dev/null +++ b/tasks/drivers/kvm/nova_compute_kvm_install_source.yml @@ -0,0 +1,63 @@ +--- +# Copyright 2018, SUSE Linux GmbH +# +# 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. + +# Note (odyssey4me): +# These python libraries have C bindings which tend to be very +# particular about the version of their companion packages. +# To ensure things run smoothly for stable releases, we opt to +# use the distro packages for these and symlink the appropriate +# library files and binding into the venv. + +- name: Link guestfs into the venv + file: + src: "{{ linkfiles.name }}" + dest: "{{ nova_bin | dirname }}/lib/python2.7/{{ linkfiles.name | basename }}" + state: "{{ linkfiles.state }}" + force: "yes" + with_items: + - { state: link, name: "/usr/lib/python2.7/dist-packages/libguestfsmod.so" } + - { state: link, name: "/usr/lib/python2.7/dist-packages/guestfs.py" } + loop_control: + loop_var: linkfiles + tags: + - nova-pip-packages + +- name: Register libvirt module path + command: python -c 'import libvirt; print libvirt.__file__' + changed_when: false + register: _libvirt_module_path + tags: + - nova-pip-packages + +- name: Register libvirt-python files + shell: >- + {{ (ansible_pkg_mgr == 'apt') | ternary('dpkg -L python-libvirt', 'rpm -ql libvirt-python') }} + | grep '^{{ _libvirt_module_path.stdout | dirname }}/' + args: + warn: no + changed_when: false + register: _libvirt_python_files + tags: + - nova-pip-packages + +- name: Link the libvirt files into venv + file: + src: "{{ item }}" + dest: "{{ nova_bin | dirname }}/lib/python2.7/site-packages/{{ item | basename }}" + state: link + force: yes + with_items: "{{ _libvirt_python_files.stdout_lines }}" + tags: + - nova-pip-packages diff --git a/tasks/drivers/lxd/nova_compute_lxd.yml b/tasks/drivers/lxd/nova_compute_lxd.yml index 8834d205..45f96f4e 100644 --- a/tasks/drivers/lxd/nova_compute_lxd.yml +++ b/tasks/drivers/lxd/nova_compute_lxd.yml @@ -13,22 +13,9 @@ # 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 }}" - state: "{{ nova_pip_package_state }}" - virtualenv: "{{ nova_bin | dirname }}" - virtualenv_site_packages: "no" - extra_args: >- - {{ nova_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} - {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} - {{ pip_install_options | default('') }} - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - tags: - - nova-pip-packages +- name: Install nova lxd packages from PIP + include_tasks: nova_compute_lxd_source.yml + when: nova_install_method == 'source' - name: Add nova user to lxd group user: diff --git a/tasks/drivers/lxd/nova_compute_lxd_source.yml b/tasks/drivers/lxd/nova_compute_lxd_source.yml new file mode 100644 index 00000000..110ce70e --- /dev/null +++ b/tasks/drivers/lxd/nova_compute_lxd_source.yml @@ -0,0 +1,31 @@ +--- +# Copyright 2018, SUSE Linux GmbH. +# +# 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 }}" + state: "{{ nova_pip_package_state }}" + virtualenv: "{{ nova_bin | dirname }}" + virtualenv_site_packages: "no" + extra_args: >- + {{ nova_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} + {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} + {{ pip_install_options | default('') }} + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + tags: + - nova-pip-packages diff --git a/tasks/main.yml b/tasks/main.yml index 97154c5c..4c80d079 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -53,6 +53,21 @@ tags: - always +- name: Fail if service was deployed using a different installation method + fail: + msg: "Switching installation methods for OpenStack services is not supported" + when: + - ansible_local is defined + - ansible_local.openstack_ansible is defined + - ansible_local.openstack_ansible.nova is defined + - ansible_local.openstack_ansible.nova.install_method is defined + - ansible_local.openstack_ansible.nova.install_method != nova_install_method + +- name: Gather variables for installation method + include_vars: "{{ nova_install_method }}_install.yml" + tags: + - always + - include_tasks: nova_virt_detect.yml tags: - always diff --git a/tasks/nova_install.yml b/tasks/nova_install.yml index 1c639171..387f439a 100644 --- a/tasks/nova_install.yml +++ b/tasks/nova_install.yml @@ -20,33 +20,24 @@ - "nova_virt_type == 'powervm'" - "ansible_pkg_mgr == 'apt'" +- name: Record the installation method + ini_file: + dest: "/etc/ansible/facts.d/openstack_ansible.fact" + section: "nova" + option: "install_method" + value: "{{ nova_install_method }}" + +- name: Refresh local facts to ensure the nova section is present + setup: + filter: ansible_local + gather_subset: "!all" + - name: Install distro packages package: name: "{{ nova_package_list }}" state: "{{ nova_package_state }}" update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}" cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}" - -- name: Create developer mode constraint file - copy: - dest: "/opt/developer-pip-constraints.txt" - content: | - {% for item in nova_developer_constraints %} - {{ item }} - {% endfor %} - when: - - nova_developer_mode | bool - tags: - - nova-pip-packages - -- name: Install required pip packages - pip: - name: "{{ nova_requires_pip_packages }}" - state: "{{ nova_pip_package_state }}" - extra_args: >- - {{ nova_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} - {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} - {{ pip_install_options | default('') }} register: install_packages until: install_packages|success retries: 5 @@ -54,113 +45,6 @@ tags: - nova-pip-packages -- name: Retrieve checksum for venv download - uri: - url: "{{ nova_venv_download_url | replace('tgz', 'checksum') }}" - return_content: yes - register: nova_venv_checksum - when: - - nova_venv_download | bool - tags: - - nova-pip-packages - - always - -- name: Attempt venv download - get_url: - url: "{{ nova_venv_download_url }}" - dest: "/var/cache/{{ nova_venv_download_url | basename }}" - checksum: "sha1:{{ nova_venv_checksum.content | trim }}" - register: nova_get_venv - when: - - nova_venv_download | bool - tags: - - nova-pip-packages - - always - -- name: Remove existing venv - file: - path: "{{ nova_bin | dirname }}" - state: absent - when: - - nova_get_venv | changed - tags: - - nova-pip-packages - -- name: Create nova venv dir - file: - path: "{{ nova_bin | dirname }}" - state: directory - register: nova_venv_dir - when: - - nova_get_venv | changed - tags: - - nova-pip-packages - -- name: Unarchive pre-built venv - unarchive: - src: "/var/cache/{{ nova_venv_download_url | basename }}" - dest: "{{ nova_bin | dirname }}" - copy: "no" - when: - - nova_get_venv | changed - notify: - - Manage LB - - Restart nova services - tags: - - nova-pip-packages - -- name: Install pip packages - pip: - name: "{{ nova_pip_packages }}" - state: "{{ nova_pip_package_state }}" - virtualenv: "{{ nova_bin | dirname }}" - virtualenv_site_packages: "no" - extra_args: >- - {{ nova_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} - {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} - {{ pip_install_options | default('') }} - register: install_packages - until: install_packages|success - retries: 5 - delay: 2 - when: - - nova_get_venv | failed or nova_get_venv | skipped - notify: - - Manage LB - - Restart nova services - tags: - - nova-pip-packages - -- name: Remove python from path first (CentOS, openSUSE) - file: - path: "{{ nova_bin | dirname }}/bin/python2.7" - state: "absent" - when: - - ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] - - nova_get_venv | changed - -# NOTE(odyssey4me): -# We reinitialize the venv to ensure that the right -# version of python is in the venv, but we do not -# want virtualenv to also replace pip, setuptools -# and wheel so we tell it not to. -# We do not use --always-copy for CentOS/SuSE due -# to https://github.com/pypa/virtualenv/issues/565 -- name: Update virtualenv path - shell: | - find {{ nova_bin }} -name \*.pyc -delete - sed -si '1s/^.*python.*$/#!{{ nova_bin | replace ('/','\/') }}\/python/' {{ nova_bin }}/* - virtualenv {{ nova_bin | dirname }} \ - {{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} \ - --no-pip \ - --no-setuptools \ - --no-wheel - when: - - nova_get_venv | changed - tags: - - skip_ansible_lint - - nova-pip-packages - - include_tasks: "consoles/nova_console_{{ nova_console_type }}_install.yml" when: - "nova_services['nova-novncproxy']['group'] in group_names or @@ -172,28 +56,28 @@ - nova-novnc-console - nova-spice-console +- name: Install nova packages from PIP + include_tasks: nova_install_source.yml + when: nova_install_method == 'source' + - name: Initialise the upgrade facts ini_file: dest: "/etc/ansible/facts.d/openstack_ansible.fact" section: nova - option: "{{ item }}" - value: True + option: "{{ item.name }}" + value: "{{ item.state }}" with_items: - - "need_service_restart" - - "need_online_data_migrations" + - name: "need_service_restart" + state: "True" + - name: "need_online_data_migrations" + state: "True" when: - - (nova_get_venv | changed) or - (nova_venv_dir | changed) or + - (nova_install_method == 'source' and + ((nova_get_venv | changed) or + (nova_venv_dir | changed))) or (install_packages | changed) or (ansible_local is not defined) or ('openstack_ansible' not in ansible_local) or ('nova' not in ansible_local['openstack_ansible']) or ('need_online_data_migrations' not in ansible_local['openstack_ansible']['nova']) or ('need_service_restart' not in ansible_local['openstack_ansible']['nova']) - -- name: Record the venv tag deployed - ini_file: - dest: "/etc/ansible/facts.d/openstack_ansible.fact" - section: nova - option: venv_tag - value: "{{ nova_venv_tag }}" diff --git a/tasks/nova_install_source.yml b/tasks/nova_install_source.yml new file mode 100644 index 00000000..8091a37d --- /dev/null +++ b/tasks/nova_install_source.yml @@ -0,0 +1,156 @@ +--- +# Copyright 2018, SUSE Linux GmbH. +# +# 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: Create developer mode constraint file + copy: + dest: "/opt/developer-pip-constraints.txt" + content: | + {% for item in nova_developer_constraints %} + {{ item }} + {% endfor %} + when: + - nova_developer_mode | bool + tags: + - nova-pip-packages + +- name: Install required pip packages + pip: + name: "{{ nova_requires_pip_packages }}" + state: "{{ nova_pip_package_state }}" + extra_args: >- + {{ nova_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} + {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} + {{ pip_install_options | default('') }} + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + tags: + - nova-pip-packages + +- name: Retrieve checksum for venv download + uri: + url: "{{ nova_venv_download_url | replace('tgz', 'checksum') }}" + return_content: yes + register: nova_venv_checksum + when: + - nova_venv_download | bool + tags: + - nova-pip-packages + - always + +- name: Attempt venv download + get_url: + url: "{{ nova_venv_download_url }}" + dest: "/var/cache/{{ nova_venv_download_url | basename }}" + checksum: "sha1:{{ nova_venv_checksum.content | trim }}" + register: nova_get_venv + when: + - nova_venv_download | bool + tags: + - nova-pip-packages + - always + +- name: Remove existing venv + file: + path: "{{ nova_bin | dirname }}" + state: absent + when: + - nova_get_venv | changed + tags: + - nova-pip-packages + +- name: Create nova venv dir + file: + path: "{{ nova_bin | dirname }}" + state: directory + register: nova_venv_dir + when: + - nova_get_venv | changed + tags: + - nova-pip-packages + +- name: Unarchive pre-built venv + unarchive: + src: "/var/cache/{{ nova_venv_download_url | basename }}" + dest: "{{ nova_bin | dirname }}" + copy: "no" + when: + - nova_get_venv | changed + notify: + - Manage LB + - Restart nova services + tags: + - nova-pip-packages + +- name: Install pip packages + pip: + name: "{{ nova_pip_packages }}" + state: "{{ nova_pip_package_state }}" + virtualenv: "{{ nova_bin | dirname }}" + virtualenv_site_packages: "no" + extra_args: >- + {{ nova_developer_mode | ternary(pip_install_developer_constraints | default('--constraint /opt/developer-pip-constraints.txt'), '') }} + {{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }} + {{ pip_install_options | default('') }} + register: install_packages + until: install_packages|success + retries: 5 + delay: 2 + when: + - nova_get_venv | failed or nova_get_venv | skipped + notify: + - Manage LB + - Restart nova services + tags: + - nova-pip-packages + +- name: Remove python from path first (CentOS, openSUSE) + file: + path: "{{ nova_bin | dirname }}/bin/python2.7" + state: "absent" + when: + - ansible_pkg_mgr in ['yum', 'dnf', 'zypper'] + - nova_get_venv | changed + +# NOTE(odyssey4me): +# We reinitialize the venv to ensure that the right +# version of python is in the venv, but we do not +# want virtualenv to also replace pip, setuptools +# and wheel so we tell it not to. +# We do not use --always-copy for CentOS/SuSE due +# to https://github.com/pypa/virtualenv/issues/565 +- name: Update virtualenv path + shell: | + find {{ nova_bin }} -name \*.pyc -delete + sed -si '1s/^.*python.*$/#!{{ nova_bin | replace ('/','\/') }}\/python/' {{ nova_bin }}/* + virtualenv {{ nova_bin | dirname }} \ + {{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} \ + --no-pip \ + --no-setuptools \ + --no-wheel + when: + - nova_get_venv | changed + tags: + - skip_ansible_lint + - nova-pip-packages + - Restart nova services + +- name: Record the venv tag deployed + ini_file: + dest: "/etc/ansible/facts.d/openstack_ansible.fact" + section: nova + option: venv_tag + value: "{{ nova_venv_tag }}" diff --git a/templates/nova-uwsgi.ini.j2 b/templates/nova-uwsgi.ini.j2 index 9f0bc369..89a05820 100644 --- a/templates/nova-uwsgi.ini.j2 +++ b/templates/nova-uwsgi.ini.j2 @@ -3,7 +3,9 @@ uid = {{ nova_system_user_name }} gid = {{ nova_system_group_name }} +{% if nova_install_method == 'source' %} virtualenv = /openstack/venvs/nova-{{ nova_venv_tag }} +{% endif %} wsgi-file = {{ nova_bin }}/{{ item.wsgi_name }} http = 0.0.0.0:{{ item.uwsgi_port }} diff --git a/tox.ini b/tox.ini index cc22310f..4ba34bb1 100644 --- a/tox.ini +++ b/tox.ini @@ -85,6 +85,12 @@ commands = commands = bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" +[testenv:distro_install] +setenv = + {[testenv]setenv} + ANSIBLE_PARAMETERS=-e @{toxinidir}/tests/common/test-distro_install-vars.yml +commands = + bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" [testenv:upgrade] setenv = diff --git a/vars/distro_install.yml b/vars/distro_install.yml new file mode 100644 index 00000000..732d578a --- /dev/null +++ b/vars/distro_install.yml @@ -0,0 +1,54 @@ +--- +# Copyright 2018, SUSE Linux GmbH. +# +# 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. + +# +# Compile a list of the distro packages to install based on +# whether the host is in the host group and the service is +# enabled. +# +nova_package_list: |- + {% set packages = nova_distro_packages %} + {% if nova_services['nova-novncproxy']['group'] in group_names or + nova_services['nova-spicehtml5proxy']['group'] in group_names or + nova_services['nova-serialconsole-proxy']['group'] in group_names %} + {% if nova_console_type == 'novnc' %} + {% set _ = packages.extend(nova_novnc_distro_packages) %} + {% set _ = packages.extend(nova_service_extra_distro_packages['novnc']) %} + {% endif %} + {% if nova_console_type == 'spice' %} + {% set _ = packages.extend(nova_service_extra_distro_packages['spice']) %} + {% endif %} + {% endif %} + {% if nova_services['nova-compute']['group'] in group_names %} + {% if nova_virt_type in ['kvm', 'qemu'] %} + {% set _ = packages.extend(nova_compute_kvm_distro_packages) %} + {% set _ = packages.extend(nova_service_extra_distro_packages['kvm']) %} + {% if nova_compute_ksm_enabled %} + {% set _ = packages.extend(nova_compute_ksm_packages) %} + {% endif %} + {% elif nova_virt_type == 'lxd' %} + {% set _ = packages.extend(nova_compute_lxd_distro_packages) %} + {% set _ = packages.extend(nova_service_extra_distro_packages['lxd']) %} + {% elif nova_virt_type == 'powervm' %} + {% set _ = packages.extend(nova_compute_powervm_distro_packages) %} + {% endif %} + {% if nova_barbican_enabled | bool %} + {% set _ = packages.extend(nova_compute_barbican_distro_packages) %} + {% endif %} + {% endif %} + {% set _ = packages.extend(nova_service_distro_packages) %} + {{ packages }} + +_nova_bin: '/usr/bin' diff --git a/vars/main.yml b/vars/main.yml index f8a76514..d2075dce 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -13,37 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -# -# Compile a list of the distro packages to install based on -# whether the host is in the host group and the service is -# enabled. -# -nova_package_list: |- - {% set packages = nova_distro_packages %} - {% if nova_services['nova-novncproxy']['group'] in group_names or - nova_services['nova-spicehtml5proxy']['group'] in group_names or - nova_services['nova-serialconsole-proxy']['group'] in group_names %} - {% if nova_console_type == 'novnc' %} - {% set _ = packages.extend(nova_novnc_distro_packages) %} - {% endif %} - {% endif %} - {% if nova_services['nova-compute']['group'] in group_names %} - {% if nova_virt_type in ['kvm', 'qemu'] %} - {% set _ = packages.extend(nova_compute_kvm_distro_packages) %} - {% if nova_compute_ksm_enabled %} - {% set _ = packages.extend(nova_compute_ksm_packages) %} - {% endif %} - {% elif nova_virt_type == 'lxd' %} - {% set _ = packages.extend(nova_compute_lxd_distro_packages) %} - {% elif nova_virt_type == 'powervm' %} - {% set _ = packages.extend(nova_compute_powervm_distro_packages) %} - {% endif %} - {% if nova_barbican_enabled | bool %} - {% set _ = packages.extend(nova_compute_barbican_distro_packages) %} - {% endif %} - {% endif %} - {{ packages }} - # # Compile a list of the services on a host based on whether # the host is in the host group and the service is enabled. diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 0b0da943..b6128516 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -23,9 +23,41 @@ nova_distro_packages: - genisoimage - git - iptables - - postgresql-devel - - which + - python-keystoneclient + - python-openstackclient + +nova_devel_distro_packages: - libxml2-devel + - postgresql-devel + - python-httplib2 + - which + +nova_service_distro_packages: + - openstack-nova + - openstack-nova-api + - openstack-nova-cells + - openstack-nova-compute + - openstack-nova-conductor + - openstack-nova-console + - openstack-nova-migration + - openstack-nova-network + - openstack-nova-novncproxy + - openstack-nova-placement-api + - openstack-nova-scheduler + - openstack-nova-serialproxy + - python-memcached + - python-novaclient + - python2-PyMySQL + - uwsgi + - uwsgi-plugin-python + +nova_service_extra_distro_packages: + kvm: [] + lxd: [] + novnc: + - openstack-nova-novncproxy + spice: + - openstack-nova-spicehtml5proxy nova_novnc_distro_packages: - js-jquery @@ -68,3 +100,5 @@ novalink_gpg_keys: [] # Needed for nginx cleanup for O -> P upgrades. Remove in Q nova_nginx_conf_path: "conf.d" + +nova_uwsgi_bin: '/usr/sbin' diff --git a/vars/source_install.yml b/vars/source_install.yml new file mode 100644 index 00000000..febd9e0b --- /dev/null +++ b/vars/source_install.yml @@ -0,0 +1,49 @@ +--- +# Copyright 2017, 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. + +# +# Compile a list of the distro packages to install based on +# whether the host is in the host group and the service is +# enabled. +# +nova_package_list: |- + {% set packages = nova_distro_packages %} + {% if nova_services['nova-novncproxy']['group'] in group_names or + nova_services['nova-spicehtml5proxy']['group'] in group_names or + nova_services['nova-serialconsole-proxy']['group'] in group_names %} + {% if nova_console_type == 'novnc' %} + {% set _ = packages.extend(nova_novnc_distro_packages) %} + {% endif %} + {% endif %} + {% if nova_services['nova-compute']['group'] in group_names %} + {% if nova_virt_type in ['kvm', 'qemu'] %} + {% set _ = packages.extend(nova_compute_kvm_distro_packages) %} + {% if nova_compute_ksm_enabled %} + {% set _ = packages.extend(nova_compute_ksm_packages) %} + {% endif %} + {% elif nova_virt_type == 'lxd' %} + {% set _ = packages.extend(nova_compute_lxd_distro_packages) %} + {% elif nova_virt_type == 'powervm' %} + {% set _ = packages.extend(nova_compute_powervm_distro_packages) %} + {% endif %} + {% if nova_barbican_enabled | bool %} + {% set _ = packages.extend(nova_compute_barbican_distro_packages) %} + {% endif %} + {% endif %} + {% set _ = packages.extend(nova_devel_distro_packages) %} + {{ packages }} + +_nova_bin: "/openstack/venvs/nova-{{ nova_venv_tag }}/bin" +nova_uwsgi_bin: "{{ _nova_bin }}" diff --git a/vars/suse-42.yml b/vars/suse-42.yml index 064e6363..88cf0143 100644 --- a/vars/suse-42.yml +++ b/vars/suse-42.yml @@ -24,9 +24,42 @@ nova_distro_packages: - genisoimage - git-core - iptables - - postgresql-devel - - which + - python-keystoneclient + - python-openstackclient + +nova_devel_distro_packages: - libxml2-devel + - postgresql-devel + - python-httplib2 + - which + +nova_service_distro_packages: + - openstack-nova + - openstack-nova-api + - openstack-nova-cells + - openstack-nova-compute + - openstack-nova-conductor + - openstack-nova-console + - openstack-nova-consoleauth + - openstack-nova-network + - openstack-nova-novncproxy + - openstack-nova-placement-api + - openstack-nova-scheduler + - openstack-nova-serialproxy + - openstack-nova-vncproxy + - python-keystonemiddleware + - python-memcached + - python-novaclient + - python-PyMySQL + - uwsgi + - uwsgi-python + +nova_service_extra_distro_packages: + kvm: [] + lxd: [] + novnc: + - openstack-nova-novncproxy + spice: [] nova_novnc_distro_packages: - python-websockify @@ -77,3 +110,5 @@ novalink_gpg_keys: [] # Needed for nginx cleanup for O -> P upgrades. Remove in Q nova_nginx_conf_path: "conf.d" + +nova_uwsgi_bin: '/usr/sbin' diff --git a/vars/ubuntu-16.04.yml b/vars/ubuntu-16.04.yml index c408a6f4..d90714ba 100644 --- a/vars/ubuntu-16.04.yml +++ b/vars/ubuntu-16.04.yml @@ -23,9 +23,43 @@ libvirt_service_name: libvirtd nova_distro_packages: - genisoimage - git - - libpq-dev - iptables + - python-keystoneclient + - python-openstackclient + +nova_devel_distro_packages: + - libpq-dev - libxml2-dev + - python-httplib2 + +nova_service_distro_packages: + - nova-api + - nova-cells + - nova-conductor + - nova-console + - nova-consoleauth + - nova-network + - nova-novncproxy + - nova-placement-api + - nova-scheduler + - nova-serialproxy + - nova-volume + - python-memcache + - python-novaclient + - python-pymysql + - python-sqlalchemy + - uwsgi + - uwsgi-plugin-python + +nova_service_extra_distro_packages: + kvm: + - nova-compute-kvm + lxd: + - nova-compute-lxd + novnc: + - nova-novncproxy + spice: + - nova-spiceproxy nova_novnc_distro_packages: - libjs-jquery @@ -112,3 +146,5 @@ novalink_gpg_keys: # Needed for nginx cleanup for O -> P upgrades. Remove in Q nova_nginx_conf_path: "sites-available" + +nova_uwsgi_bin: '/usr/bin' diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index e0270cd4..c8905c64 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -26,6 +26,11 @@ - openstack-ansible-upgrade-ubuntu-xenial - openstack-ansible-lxd-ubuntu-xenial - openstack-ansible-nova-ssl-nv + - openstack-ansible-functional-distro_install-centos-7 + - openstack-ansible-functional-distro_install-opensuse-423 + # NOTE(hwoarang) xenial does not currently work. It needs investigation + - openstack-ansible-functional-distro_install-ubuntu-xenial: + voting: false experimental: jobs: - openstack-ansible-integrated-deploy-aio @@ -40,3 +45,5 @@ - openstack-ansible-functional-ubuntu-xenial - openstack-ansible-upgrade-ubuntu-xenial - openstack-ansible-lxd-ubuntu-xenial + - openstack-ansible-functional-distro_install-centos-7 + - openstack-ansible-functional-distro_install-opensuse-423