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.

Change-Id: I2435793b73e0a30131b4710b6e7d29dacbb7e6fa
Implements: blueprint openstack-distribution-packages
This commit is contained in:
Markos Chandras 2018-05-21 13:09:19 +01:00
parent 9f562499f1
commit 3ac7ae6ea7
13 changed files with 277 additions and 118 deletions

View File

@ -27,6 +27,9 @@ debug: False
heat_package_state: "latest"
heat_pip_package_state: "latest"
# Set installation method.
heat_install_method: "source"
heat_git_repo: https://git.openstack.org/openstack/heat
heat_git_install_branch: master
heat_developer_mode: false
@ -35,7 +38,7 @@ heat_developer_constraints:
# Name of the virtual env to deploy into
heat_venv_tag: untagged
heat_bin: "/openstack/venvs/heat-{{ heat_venv_tag }}/bin"
heat_bin: "{{ _heat_bin }}"
# venv_download, even when true, will use the fallback method of building the
# venv from scratch if the venv download fails.
@ -218,8 +221,8 @@ heat_services:
wsgi_name: heat-wsgi-api
uwsgi_port: "{{ heat_service_port }}"
uwsgi_bind_address: "{{ heat_api_uwsgi_bind_address }}"
execstarts: "{{ heat_bin }}/uwsgi --autoload --ini /etc/uwsgi/heat-api.ini"
execreloads: "{{ heat_bin }}/uwsgi --reload /var/run/heat-api/heat-api.pid"
execstarts: "{{ heat_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/heat-api.ini"
execreloads: "{{ heat_uwsgi_bin }}/uwsgi --reload /var/run/heat-api/heat-api.pid"
heat-api-cfn:
group: heat_api_cfn
service_name: heat-api-cfn
@ -230,12 +233,12 @@ heat_services:
wsgi_name: heat-wsgi-api-cfn
uwsgi_port: "{{ heat_cfn_service_port }}"
uwsgi_bind_address: "{{ heat_api_cfn_uwsgi_bind_address }}"
execstarts: "{{ heat_bin }}/uwsgi --autoload --ini /etc/uwsgi/heat-api-cfn.ini"
execreloads: "{{ heat_bin }}/uwsgi --reload /var/run/heat-api-cfn/heat-api-cfn.pid"
execstarts: "{{ heat_uwsgi_bin }}/uwsgi --autoload --ini /etc/uwsgi/heat-api-cfn.ini"
execreloads: "{{ heat_uwsgi_bin }}/uwsgi --reload /var/run/heat-api-cfn/heat-api-cfn.pid"
heat-engine:
group: heat_engine
service_name: heat-engine
execstarts: "{{ heat_bin }}/heat-engine"
execstarts: "{{ heat_uwsgi_bin }}/heat-engine"
init_config_overrides: "{{ heat_engine_init_overrides }}"
start_order: 1

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

View File

@ -13,9 +13,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Record the installation method
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: "heat"
option: "install_method"
value: "{{ heat_install_method }}"
- name: Refresh local facts to ensure the heat section is present
setup:
filter: ansible_local
gather_subset: "!all"
- name: Install distro packages
package:
name: "{{ heat_distro_packages }}"
name: "{{ heat_package_list }}"
state: "{{ heat_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
@ -24,113 +36,6 @@
retries: 5
delay: 2
- name: Create developer mode constraint file
copy:
dest: "/opt/developer-pip-constraints.txt"
content: |
{% for item in heat_developer_constraints %}
{{ item }}
{% endfor %}
when: heat_developer_mode | bool
- name: Install requires pip packages
pip:
name: "{{ heat_requires_pip_packages }}"
state: "{{ heat_pip_package_state }}"
extra_args: >-
{{ heat_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: "{{ heat_venv_download_url | replace('tgz', 'checksum') }}"
return_content: yes
register: heat_venv_checksum
when: heat_venv_download | bool
- name: Attempt venv download
get_url:
url: "{{ heat_venv_download_url }}"
dest: "/var/cache/{{ heat_venv_download_url | basename }}"
checksum: "sha1:{{ heat_venv_checksum.content | trim }}"
register: heat_get_venv
when: heat_venv_download | bool
- name: Remove existing venv
file:
path: "{{ heat_bin | dirname }}"
state: absent
when: heat_get_venv | changed
- name: Create heat venv dir
file:
path: "{{ heat_bin | dirname }}"
state: directory
mode: "0755"
register: heat_venv_dir
when: heat_get_venv | changed
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ heat_venv_download_url | basename }}"
dest: "{{ heat_bin | dirname }}"
copy: "no"
when: heat_get_venv | changed
notify: Restart heat services
- name: Install pip packages
pip:
name: "{{ heat_pip_packages }}"
state: "{{ heat_pip_package_state }}"
virtualenv: "{{ heat_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: >-
{{ heat_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: heat_get_venv | failed or heat_get_venv | skipped
notify: Restart heat services
- name: Remove python from path first (CentOS, openSUSE)
file:
path: "{{ heat_bin | dirname }}/bin/python2.7"
state: "absent"
when:
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
- heat_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 {{ heat_bin }} -name \*.pyc -delete
sed -si '1s/^.*python.*$/#!{{ heat_bin | replace ('/','\/') }}\/python/' {{ heat_bin }}/*
virtualenv {{ heat_bin | dirname }} \
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} \
--no-pip \
--no-setuptools \
--no-wheel
when: heat_get_venv | changed
tags:
- skip_ansible_lint
- name: Record the venv tag deployed
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: heat
option: venv_tag
value: "{{ heat_venv_tag }}"
- name: Install heat packages from PIP
include_tasks: heat_install_source.yml
when: heat_install_method == 'source'

View File

@ -0,0 +1,125 @@
---
# 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 heat_developer_constraints %}
{{ item }}
{% endfor %}
when: heat_developer_mode | bool
- name: Install requires pip packages
pip:
name: "{{ heat_requires_pip_packages }}"
state: "{{ heat_pip_package_state }}"
extra_args: >-
{{ heat_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: "{{ heat_venv_download_url | replace('tgz', 'checksum') }}"
return_content: yes
register: heat_venv_checksum
when: heat_venv_download | bool
- name: Attempt venv download
get_url:
url: "{{ heat_venv_download_url }}"
dest: "/var/cache/{{ heat_venv_download_url | basename }}"
checksum: "sha1:{{ heat_venv_checksum.content | trim }}"
register: heat_get_venv
when: heat_venv_download | bool
- name: Remove existing venv
file:
path: "{{ heat_bin | dirname }}"
state: absent
when: heat_get_venv | changed
- name: Create heat venv dir
file:
path: "{{ heat_bin | dirname }}"
state: directory
mode: "0755"
register: heat_venv_dir
when: heat_get_venv | changed
- name: Unarchive pre-built venv
unarchive:
src: "/var/cache/{{ heat_venv_download_url | basename }}"
dest: "{{ heat_bin | dirname }}"
copy: "no"
when: heat_get_venv | changed
notify: Restart heat services
- name: Install pip packages
pip:
name: "{{ heat_pip_packages }}"
state: "{{ heat_pip_package_state }}"
virtualenv: "{{ heat_bin | dirname }}"
virtualenv_site_packages: "no"
extra_args: >-
{{ heat_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: heat_get_venv | failed or heat_get_venv | skipped
notify: Restart heat services
- name: Remove python from path first (CentOS, openSUSE)
file:
path: "{{ heat_bin | dirname }}/bin/python2.7"
state: "absent"
when:
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
- heat_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 {{ heat_bin }} -name \*.pyc -delete
sed -si '1s/^.*python.*$/#!{{ heat_bin | replace ('/','\/') }}\/python/' {{ heat_bin }}/*
virtualenv {{ heat_bin | dirname }} \
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} \
--no-pip \
--no-setuptools \
--no-wheel
when: heat_get_venv | changed
tags:
- skip_ansible_lint
- name: Record the venv tag deployed
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: heat
option: venv_tag
value: "{{ heat_venv_tag }}"

View File

@ -13,6 +13,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.
- 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.heat is defined
- ansible_local.openstack_ansible.heat.install_method is defined
- ansible_local.openstack_ansible.heat.install_method != heat_install_method
- name: Gather variables for each operating system
include_vars: "{{ item }}"
with_first_found:
@ -32,6 +42,11 @@
tags:
- always
- name: Gather variables for installation method
include_vars: "{{ heat_install_method }}_install.yml"
tags:
- always
- include: heat_pre_install.yml
tags:
- heat-install

View File

@ -2,7 +2,9 @@
uid = {{ heat_system_user_name }}
gid = {{ heat_system_group_name }}
{% if heat_install_method == 'source' %}
virtualenv = /openstack/venvs/heat-{{ heat_venv_tag }}
{% endif %}
wsgi-file = {{ heat_bin }}/{{ item.wsgi_name }}
http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }}

10
tox.ini
View File

@ -101,6 +101,16 @@ commands =
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
[testenv:distro_install]
deps =
{[testenv:ansible]deps}
setenv =
{[testenv]setenv}
ANSIBLE_PARAMETERS=-e heat_install_method=distro
commands =
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh"
[testenv:ssl]
deps =
{[testenv:ansible]deps}

18
vars/distro_install.yml Normal file
View File

@ -0,0 +1,18 @@
---
# 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.
heat_package_list: "{{ heat_service_distro_packages }}"
heat_bin: "/usr/bin"

View File

@ -18,3 +18,13 @@ heat_distro_packages:
- libxslt
- which
heat_service_distro_packages:
- openstack-heat-agents
- openstack-heat-api
- openstack-heat-api-cfn
- openstack-heat-engine
- openstack-heat-ui
- uwsgi
- uwsgi-plugin-python
heat_uwsgi_bin: '/usr/sbin'

19
vars/source_install.yml Normal file
View File

@ -0,0 +1,19 @@
---
# 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.
heat_package_list: "{{ heat_distro_packages }}"
_heat_bin: "/openstack/venvs/heat-{{ heat_venv_tag }}/bin"
heat_uwsgi_bin: "{{ _keystone_bin }}"

View File

@ -1 +0,0 @@
redhat-7.yml

30
vars/suse-42.yml Normal file
View File

@ -0,0 +1,30 @@
---
# 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.
heat_distro_packages:
- rsync
- libxslt
- which
heat_service_distro_packages:
- openstack-heat
- openstack-heat-api
- openstack-heat-api-cfn
- openstack-heat-engine
- openstack-heat-templates
- uwsgi
- uwsgi-python
heat_uwsgi_bin: '/usr/sbin'

View File

@ -19,3 +19,12 @@ cache_timeout: 600
heat_distro_packages:
- rsync
- libxslt1.1
heat_service_distro_packages:
- heat-api
- heat-api-cfn
- heat-engine
- uwsgi
- uwsgi-plugin-python
heat_uwsgi_bin: '/usr/bin'

View File

@ -20,6 +20,11 @@
- openstack-ansible-functional-opensuse-423
- openstack-ansible-functional-ubuntu-xenial
- openstack-ansible-heat-ssl-nv
- openstack-ansible-functional-distro_install-ubuntu-xenial
# NOTE(hwoarang) Centos7 is having some troubles with repo dependencies
# so disabling until it's investigated.
- openstack-ansible-functional-distro_install-centos-7-nv
- openstack-ansible-functional-distro_install-opensuse-423
experimental:
jobs:
- openstack-ansible-integrated-deploy-aio
@ -29,3 +34,5 @@
- openstack-ansible-functional-centos-7
- openstack-ansible-functional-opensuse-423
- openstack-ansible-functional-ubuntu-xenial
- openstack-ansible-functional-distro_install-ubuntu-xenial
- openstack-ansible-functional-distro_install-opensuse-423