Merge "Add support for using distribution packages for OpenStack services"

This commit is contained in:
Zuul 2018-05-10 19:49:43 +00:00 committed by Gerrit Code Review
commit ac0ded6738
13 changed files with 249 additions and 123 deletions

View File

@ -16,6 +16,9 @@
## Verbosity Options ## Verbosity Options
debug: False debug: False
# Set installation method
glance_install_method: "source"
# Set the package install state for distribution and pip packages # Set the package install state for distribution and pip packages
# Options are 'present' and 'latest' # Options are 'present' and 'latest'
glance_package_state: "latest" glance_package_state: "latest"
@ -29,13 +32,13 @@ glance_developer_constraints:
# Name of the virtual env to deploy into # Name of the virtual env to deploy into
glance_venv_tag: untagged glance_venv_tag: untagged
glance_bin: "/openstack/venvs/glance-{{ glance_venv_tag }}/bin" glance_bin: "{{ _glance_bin }}"
# Set the etc dir path where glance is installed. # Set the etc dir path where glance is installed.
# This is used for role access to the db migrations. # This is used for role access to the db migrations.
# Example: # Example:
# glance_etc_dir: "/usr/local/etc/glance" # glance_etc_dir: "/usr/local/etc/glance"
glance_etc_dir: "{{ glance_bin | dirname }}/etc/glance" glance_etc_dir: "{{ _glance_etc }}/glance"
# venv_download, even when true, will use the fallback method of building the # venv_download, even when true, will use the fallback method of building the
# venv from scratch if the venv download fails. # venv from scratch if the venv download fails.
@ -255,12 +258,12 @@ glance_services:
execstarts: >- execstarts: >-
{{ glance_enable_v1_api | ternary( {{ glance_enable_v1_api | ternary(
glance_bin ~ '/glance-api', glance_bin ~ '/glance-api',
glance_bin ~ '/uwsgi --autoload --ini /etc/uwsgi/glance-api.ini') _glance_wsgi_bin ~ '/uwsgi --autoload --ini /etc/uwsgi/glance-api.ini')
}} }}
execreloads: >- execreloads: >-
{{ glance_enable_v1_api | ternary( {{ glance_enable_v1_api | ternary(
'/bin/kill -HUP $MAINPID', '/bin/kill -HUP $MAINPID',
glance_bin ~ '/uwsgi --reload /var/run/glance-api/glance-api.pid') _glance_wsgi_bin ~ '/uwsgi --reload /var/run/glance-api/glance-api.pid')
}} }}
glance-registry: glance-registry:
group: glance_registry group: glance_registry
@ -268,7 +271,7 @@ glance_services:
condition: "{{ glance_enable_v1_api | bool or glance_enable_v2_registry | bool }}" condition: "{{ glance_enable_v1_api | bool or glance_enable_v2_registry | bool }}"
init_config_overrides: "{{ glance_registry_init_overrides }}" init_config_overrides: "{{ glance_registry_init_overrides }}"
start_order: 2 start_order: 2
execstarts: "{{ glance_bin }}/glance-registry" execstarts: "{{ _glance_bin }}/glance-registry"
# Glance uWSGI settings # Glance uWSGI settings
glance_wsgi_processes_max: 16 glance_wsgi_processes_max: 16

View File

@ -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 ``glance_install_method``
variable to ``distro``.

View File

@ -85,7 +85,7 @@
- name: Install distro packages - name: Install distro packages
package: package:
name: "{{ glance_distro_packages }}" name: "{{ glance_package_list }}"
state: "{{ glance_package_state }}" state: "{{ glance_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}" update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}" cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
@ -94,134 +94,30 @@
retries: 5 retries: 5
delay: 2 delay: 2
- name: Create developer mode constraint file - name: Install glance packages from PIP
copy: include_tasks: glance_install_source.yml
dest: "/opt/developer-pip-constraints.txt" when: glance_install_method == 'source'
content: |
{% for item in glance_developer_constraints %}
{{ item }}
{% endfor %}
when: glance_developer_mode | bool
- name: Install requires pip packages
pip:
name: "{{ glance_requires_pip_packages }}"
state: "{{ glance_pip_package_state }}"
extra_args: >-
{{ glance_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
- name: Retrieve checksum for venv download
uri:
url: "{{ glance_venv_download_url | replace('tgz', 'checksum') }}"
return_content: yes
register: glance_venv_checksum
when: glance_venv_download | bool
- name: Attempt venv download
get_url:
url: "{{ glance_venv_download_url }}"
dest: "/var/cache/{{ glance_venv_download_url | basename }}"
checksum: "sha1:{{ glance_venv_checksum.content | trim }}"
register: glance_get_venv
when: glance_venv_download | bool
- name: Remove existing venv
file:
path: "{{ glance_bin | dirname }}"
state: absent
when: glance_get_venv | changed
- name: Create glance venv dir
file:
path: "{{ glance_bin | dirname }}"
state: directory
register: glance_venv_dir
when: glance_get_venv | changed
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ glance_venv_download_url | basename }}"
dest: "{{ glance_bin | dirname }}"
copy: "no"
when: glance_get_venv | changed
notify:
- Manage LB
- Restart glance services
- name: Install pip packages
pip:
name: "{{ glance_pip_packages }}"
state: "{{ glance_pip_package_state }}"
virtualenv: "{{ glance_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: >-
{{ glance_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: glance_get_venv | failed or glance_get_venv | skipped
notify:
- Manage LB
- Restart glance services
- name: Remove python from path first (CentOS, openSUSE)
file:
path: "{{ glance_bin | dirname }}/bin/python2.7"
state: "absent"
when:
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
- glance_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 {{ glance_bin }} -name \*.pyc -delete
sed -si '1s/^.*python.*$/#!{{ glance_bin | replace ('/','\/') }}\/python/' {{ glance_bin }}/*
virtualenv {{ glance_bin | dirname }} \
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} \
--no-pip \
--no-setuptools \
--no-wheel
when: glance_get_venv | changed
tags:
- skip_ansible_lint
- name: Record the need for a service restart - name: Record the need for a service restart
ini_file: ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact" dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: glance section: glance
option: need_service_restart option: "{{ item.name }}"
value: True value: "{{ item.state }}"
when: (glance_get_venv | changed) or with_items:
(glance_venv_dir | changed) or - name: "need_service_restart"
state: "True"
- name: "install_method"
state: "{{ glance_install_method }}"
when: (glance_install_method == 'source' and
((glance_get_venv | changed) or
(glance_venv_dir | changed))) or
(install_packages | changed) or (install_packages | changed) or
(ansible_local is not defined) or (ansible_local is not defined) or
('openstack_ansible' not in ansible_local) or ('openstack_ansible' not in ansible_local) or
('glance' not in ansible_local['openstack_ansible']) or ('glance' not in ansible_local['openstack_ansible']) or
('need_service_restart' not in ansible_local['openstack_ansible']['glance']) ('need_service_restart' not in ansible_local['openstack_ansible']['glance'])
- name: Record the venv tag deployed
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: glance
option: venv_tag
value: "{{ glance_venv_tag }}"
- name: Run the systemd service role - name: Run the systemd service role
include_role: include_role:
name: systemd_service name: systemd_service

View File

@ -0,0 +1,128 @@
---
# 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: Create developer mode constraint file
copy:
dest: "/opt/developer-pip-constraints.txt"
content: |
{% for item in glance_developer_constraints %}
{{ item }}
{% endfor %}
when: glance_developer_mode | bool
- name: Install requires pip packages
pip:
name: "{{ glance_requires_pip_packages }}"
state: "{{ glance_pip_package_state }}"
extra_args: >-
{{ glance_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
- name: Retrieve checksum for venv download
uri:
url: "{{ glance_venv_download_url | replace('tgz', 'checksum') }}"
return_content: yes
register: glance_venv_checksum
when: glance_venv_download | bool
- name: Attempt venv download
get_url:
url: "{{ glance_venv_download_url }}"
dest: "/var/cache/{{ glance_venv_download_url | basename }}"
checksum: "sha1:{{ glance_venv_checksum.content | trim }}"
register: glance_get_venv
when: glance_venv_download | bool
- name: Remove existing venv
file:
path: "{{ glance_bin | dirname }}"
state: absent
when: glance_get_venv | changed
- name: Create glance venv dir
file:
path: "{{ glance_bin | dirname }}"
state: directory
register: glance_venv_dir
when: glance_get_venv | changed
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ glance_venv_download_url | basename }}"
dest: "{{ glance_bin | dirname }}"
copy: "no"
when: glance_get_venv | changed
notify:
- Manage LB
- Restart glance services
- name: Install pip packages
pip:
name: "{{ glance_pip_packages }}"
state: "{{ glance_pip_package_state }}"
virtualenv: "{{ glance_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: >-
{{ glance_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: glance_get_venv | failed or glance_get_venv | skipped
notify:
- Manage LB
- Restart glance services
- name: Remove python from path first (CentOS, openSUSE)
file:
path: "{{ glance_bin | dirname }}/bin/python2.7"
state: "absent"
when:
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
- glance_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 {{ glance_bin }} -name \*.pyc -delete
sed -si '1s/^.*python.*$/#!{{ glance_bin | replace ('/','\/') }}\/python/' {{ glance_bin }}/*
virtualenv {{ glance_bin | dirname }} \
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} \
--no-pip \
--no-setuptools \
--no-wheel
when: glance_get_venv | changed
tags:
- skip_ansible_lint
- name: Record the venv tag deployed
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: glance
option: venv_tag
value: "{{ glance_venv_tag }}"

View File

@ -25,6 +25,21 @@
tags: tags:
- always - 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.glance is defined
- ansible_local.openstack_ansible.glance.install_method is defined
- ansible_local.openstack_ansible.glance.install_method != glance_install_method
- name: Gather variables for installation method
include_vars: "{{ glance_install_method }}_install.yml"
tags:
- always
- include_tasks: glance_install.yml - include_tasks: glance_install.yml
tags: tags:
- glance-install - glance-install

View File

@ -2,7 +2,9 @@
uid = {{ glance_system_user_name }} uid = {{ glance_system_user_name }}
gid = {{ glance_system_group_name }} gid = {{ glance_system_group_name }}
{% if glance_install_method == 'source' %}
virtualenv = /openstack/venvs/glance-{{ glance_venv_tag }} virtualenv = /openstack/venvs/glance-{{ glance_venv_tag }}
{% endif %}
wsgi-file = {{ glance_bin }}/{{ item.wsgi_name }} wsgi-file = {{ glance_bin }}/{{ item.wsgi_name }}
http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }} http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }}

View File

@ -100,6 +100,15 @@ deps =
commands = commands =
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
[testenv:distro_install]
deps =
{[testenv:ansible]deps}
setenv =
{[testenv]setenv}
ANSIBLE_PARAMETERS=-e glance_install_method=distro
commands =
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
[testenv:upgrade] [testenv:upgrade]
deps = deps =

20
vars/distro_install.yml Normal file
View File

@ -0,0 +1,20 @@
---
# 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.
glance_package_list: "{{ glance_distro_packages + glance_service_distro_packages }}"
_glance_bin: "/usr/bin"
_glance_etc: "/etc"
_glance_wsgi_bin: "{{ glance_wsgi_bin }}"

View File

@ -18,3 +18,10 @@ glance_distro_packages:
- libxml2-devel - libxml2-devel
- nfs-utils - nfs-utils
- rpcbind - rpcbind
glance_service_distro_packages:
- openstack-glance
- uwsgi
- uwsgi-plugin-python
glance_wsgi_bin: '/usr/sbin'

20
vars/source_install.yml Normal file
View File

@ -0,0 +1,20 @@
---
# 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.
glance_package_list: "{{ glance_distro_packages }}"
_glance_bin: "/openstack/venvs/glance-{{ glance_venv_tag }}/bin"
_glance_etc: "{{ _glance_bin | dirname + '/etc' }}"
_glance_wsgi_bin: "{{ _glance_bin }}"

View File

@ -19,3 +19,11 @@ glance_distro_packages:
- libxml2-devel - libxml2-devel
- nfs-utils - nfs-utils
- rpcbind - rpcbind
glance_service_distro_packages:
- openstack-glance
- openstack-glance-api
- uwsgi
- uwsgi-python
glance_wsgi_bin: '/usr/sbin'

View File

@ -22,3 +22,11 @@ glance_distro_packages:
- libxml2-dev - libxml2-dev
- nfs-common - nfs-common
- rpcbind - rpcbind
glance_service_distro_packages:
- glance
- glance-api
- uwsgi
- uwsgi-plugin-python
glance_wsgi_bin: '/usr/bin'

View File

@ -24,6 +24,9 @@
- openstack-ansible-v1_api_enabled - openstack-ansible-v1_api_enabled
- openstack-ansible-v2_registry_enabled - openstack-ansible-v2_registry_enabled
- openstack-ansible-glance-ssl-nv - openstack-ansible-glance-ssl-nv
- openstack-ansible-functional-distro_install-ubuntu-xenial
- openstack-ansible-functional-distro_install-centos-7
- openstack-ansible-functional-distro_install-opensuse-423
experimental: experimental:
jobs: jobs:
- openstack-ansible-integrated-deploy-aio - openstack-ansible-integrated-deploy-aio