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: I7eb1cbe2c80ee889d2ae08dcfed6a19cc1bd3415
Depends-On: Ide70b5d8f67d8c8a87e3f16671f0f7fb72338b89
Depends-On: I8de48eb1fb4c8d321098ca54b9e21270edc7ac87
Depends-On: Ia5fda5d417b79189d048c8891b84d57331df1404
Implements: blueprint openstack-distribution-packages
This commit is contained in:
Vadim Kuznetsov 2019-04-12 07:36:32 -04:00 committed by Jonathan Rosser
parent 9481d0d0c8
commit 6aa925e792
12 changed files with 151 additions and 19 deletions

View File

@ -22,6 +22,9 @@ debug: False
octavia_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}" octavia_service_setup_host: "{{ openstack_service_setup_host | default('localhost') }}"
octavia_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((octavia_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}" octavia_service_setup_host_python_interpreter: "{{ openstack_service_setup_host_python_interpreter | default((octavia_service_setup_host == 'localhost') | ternary(ansible_playbook_python, ansible_python['executable'])) }}"
# Set installation method.
octavia_install_method: "source"
## Octavia standalone (v2) ## Octavia standalone (v2)
octavia_v2: True octavia_v2: True
@ -54,7 +57,7 @@ octavia_pip_install_args: "{{ pip_install_options | default('') }}"
# Name of the virtual env to deploy into # Name of the virtual env to deploy into
octavia_venv_tag: "{{ venv_tag | default('untagged') }}" octavia_venv_tag: "{{ venv_tag | default('untagged') }}"
octavia_bin: "/openstack/venvs/octavia-{{ octavia_venv_tag }}/bin" octavia_bin: "{{ _octavia_bin }}"
octavia_clients_endpoint: internalURL octavia_clients_endpoint: internalURL
@ -177,14 +180,14 @@ octavia_services:
service_name: octavia-api service_name: octavia-api
start_order: 4 start_order: 4
init_config_overrides: "{{ octavia_api_init_overrides }}" init_config_overrides: "{{ octavia_api_init_overrides }}"
execstarts: "{{ octavia_bin }}/uwsgi --ini /etc/uwsgi/octavia-api.ini" execstarts: "{{ octavia_uwsgi_bin }}/uwsgi --ini /etc/uwsgi/octavia-api.ini"
execreloads: "{{ octavia_bin }}/uwsgi --reload /var/run/octavia-api/octavia-api.pid" execreloads: "{{ octavia_uwsgi_bin }}/uwsgi --reload /var/run/octavia-api/octavia-api.pid"
wsgi_overrides: "{{ octavia_api_uwsgi_ini_overrides }}" wsgi_overrides: "{{ octavia_api_uwsgi_ini_overrides }}"
wsgi_app: True wsgi_app: True
wsgi_name: octavia-wsgi wsgi_name: octavia-wsgi
uwsgi_port: "{{ octavia_service_port }}" uwsgi_port: "{{ octavia_service_port }}"
uwsgi_bind_address: "{{ octavia_uwsgi_bind_address }}" uwsgi_bind_address: "{{ octavia_uwsgi_bind_address }}"
program_override: "{{ octavia_bin }}/uwsgi --ini /etc/uwsgi/octavia-api.ini" program_override: "{{ octavia_uwsgi_bin }}/uwsgi --ini /etc/uwsgi/octavia-api.ini"
octavia-worker: octavia-worker:
group: octavia-worker group: octavia-worker
service_name: octavia-worker service_name: octavia-worker

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

View File

@ -13,6 +13,16 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # 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.octavia is defined
- ansible_local.openstack_ansible.octavia.install_method is defined
- ansible_local.openstack_ansible.octavia.install_method != octavia_install_method
- name: Gather variables for each operating system - name: Gather variables for each operating system
include_vars: "{{ item }}" include_vars: "{{ item }}"
with_first_found: with_first_found:
@ -38,24 +48,16 @@
tags: tags:
- octavia-config - octavia-config
- name: Gather variables for installation method
include_vars: "{{ octavia_install_method }}_install.yml"
tags:
- always
- include_tasks: octavia_pre_install.yml - include_tasks: octavia_pre_install.yml
tags: tags:
- octavia-install - octavia-install
- name: Install the python venv - include_tasks: octavia_install.yml
import_role:
name: "python_venv_build"
vars:
venv_build_constraints: "{{ octavia_git_constraints }}"
venv_install_destination_path: "{{ octavia_bin | dirname }}"
venv_install_distro_package_list: "{{ octavia_distro_packages }}"
venv_pip_install_args: "{{ octavia_pip_install_args }}"
venv_pip_packages: "{{ octavia_pip_packages | union(octavia_user_pip_packages) +
(octavia_oslomsg_amqp1_enabled | bool) | ternary(octavia_optional_oslomsg_amqp1_pip_packages, []) }}"
venv_facts_when_changed:
- section: "octavia"
option: "venv_tag"
value: "{{ octavia_venv_tag }}"
tags: tags:
- octavia-install - octavia-install

42
tasks/octavia_install.yml Normal file
View File

@ -0,0 +1,42 @@
---
- name: Record the installation method
ini_file:
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
section: "octavia"
option: "install_method"
value: "{{ octavia_install_method }}"
- name: Refresh local facts to ensure the octavia section is present
setup:
filter: ansible_local
gather_subset: "!all"
- name: Install distro packages
package:
name: "{{ octavia_package_list }}"
state: "{{ octavia_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
register: install_packages
until: install_packages is success
retries: 5
delay: 2
- name: Install the python venv
import_role:
name: "python_venv_build"
vars:
venv_build_constraints: "{{ octavia_git_constraints }}"
venv_install_destination_path: "{{ octavia_bin | dirname }}"
venv_install_distro_package_list: "{{ octavia_distro_packages }}"
venv_pip_install_args: "{{ octavia_pip_install_args }}"
venv_pip_packages: "{{ octavia_pip_packages | union(octavia_user_pip_packages) +
(octavia_oslomsg_amqp1_enabled | bool) | ternary(octavia_optional_oslomsg_amqp1_pip_packages, []) }}"
venv_facts_when_changed:
- section: "octavia"
option: "venv_tag"
value: "{{ octavia_venv_tag }}"
tags:
- octavia-install
when: octavia_install_method == 'source'

View File

@ -2,7 +2,9 @@
uid = {{ octavia_system_user_name }} uid = {{ octavia_system_user_name }}
gid = {{ octavia_system_group_name }} gid = {{ octavia_system_group_name }}
{% if octavia_install_method == 'source' %}
virtualenv = /openstack/venvs/octavia-{{ octavia_venv_tag }} virtualenv = /openstack/venvs/octavia-{{ octavia_venv_tag }}
{% endif %}
wsgi-file = {{ octavia_bin }}/{{ item.wsgi_name }} wsgi-file = {{ octavia_bin }}/{{ item.wsgi_name }}
http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }} http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }}

View File

@ -93,6 +93,12 @@ basepython = python3
commands = commands =
bash -c "{toxinidir}/tests/common/test-ansible-functional.sh" 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:linters] [testenv:linters]
basepython = python3 basepython = python3
@ -103,4 +109,3 @@ commands =
{[testenv:ansible-lint]commands} {[testenv:ansible-lint]commands}
{[testenv:ansible-syntax]commands} {[testenv:ansible-syntax]commands}
doc8 doc doc8 doc

View File

@ -21,3 +21,15 @@ octavia_distro_packages:
- iptables-persistent - iptables-persistent
- libxml2-dev - libxml2-dev
- netfilter-persistent - netfilter-persistent
octavia_service_distro_packages:
- octavia-common
- octavia-api
- octavia-health-manager
- octavia-housekeeping
- octavia-worker
- python-pymysql
- uwsgi
- uwsgi-plugin-python
octavia_uwsgi_bin: '/usr/bin'

4
vars/distro_install.yml Normal file
View File

@ -0,0 +1,4 @@
---
octavia_package_list: "{{ octavia_distro_packages + octavia_service_distro_packages + octavia_distro_openstack_clients_packages }}"
_octavia_bin: "/usr/bin"

View File

@ -18,3 +18,23 @@ octavia_distro_packages:
- iptables-services - iptables-services
- libxml2-devel - libxml2-devel
- git - git
octavia_service_distro_packages:
- openstack-octavia-common
- openstack-octavia-api
- openstack-octavia-health-manager
- openstack-octavia-housekeeping
- openstack-octavia-worker
- uwsgi
- uwsgi-plugin-python
octavia_distro_openstack_clients_packages:
- python-shade
- python-keystoneclient
- python-neutronclient
- python-novaclient
- python-cinderclient
- python-octaviaclient
- python-openstackclient
octavia_uwsgi_bin: '/usr/sbin'

5
vars/source_install.yml Normal file
View File

@ -0,0 +1,5 @@
---
octavia_package_list: "{{ octavia_distro_packages }}"
_octavia_bin: "/openstack/venvs/octavia-{{ octavia_venv_tag }}/bin"
octavia_uwsgi_bin: "{{ _octavia_bin }}"

View File

@ -43,3 +43,30 @@
vars: vars:
action: deploy action: deploy
scenario: aio_metal_octavia scenario: aio_metal_octavia
- job:
name: openstack-ansible-deploy-aio_distro_metal_octaviav2-centos-7
parent: openstack-ansible-deploy-aio
nodeset: centos-7
vars:
action: deploy
scenario: aio_metal_octaviav2
install_method: distro
- job:
name: openstack-ansible-deploy-aio_distro_metal_octavia-debian-stable
parent: openstack-ansible-deploy-aio
nodeset: debian-stable
vars:
action: deploy
scenario: aio_metal_octavia
install_method: distro
- job:
name: openstack-ansible-deploy-aio_distro_metal_octavia-ubuntu-bionic
parent: openstack-ansible-deploy-aio
nodeset: ubuntu-bionic
vars:
action: deploy
scenario: aio_metal_octavia
install_method: distro

View File

@ -23,6 +23,8 @@
- openstack-ansible-deploy-aio_metal_octavia-centos-7 - openstack-ansible-deploy-aio_metal_octavia-centos-7
- openstack-ansible-deploy-aio_metal_octavia-debian-stable - openstack-ansible-deploy-aio_metal_octavia-debian-stable
- openstack-ansible-deploy-aio_metal_octavia-ubuntu-bionic - openstack-ansible-deploy-aio_metal_octavia-ubuntu-bionic
- openstack-ansible-deploy-aio_distro_metal_octaviav2-centos-7
experimental: experimental:
jobs: jobs:
- openstack-ansible-deploy-aio_metal_octavia-opensuse-150 - openstack-ansible-deploy-aio_metal_octavia-opensuse-150
@ -31,3 +33,4 @@
- openstack-ansible-deploy-aio_metal_octavia-centos-7 - openstack-ansible-deploy-aio_metal_octavia-centos-7
- openstack-ansible-deploy-aio_metal_octavia-debian-stable - openstack-ansible-deploy-aio_metal_octavia-debian-stable
- openstack-ansible-deploy-aio_metal_octavia-ubuntu-bionic - openstack-ansible-deploy-aio_metal_octavia-ubuntu-bionic
- openstack-ansible-deploy-aio_distro_metal_octaviav2-centos-7