From 6aa925e792e6dc8f303d99595fb6406d22e95952 Mon Sep 17 00:00:00 2001 From: Vadim Kuznetsov Date: Fri, 12 Apr 2019 07:36:32 -0400 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. Change-Id: I7eb1cbe2c80ee889d2ae08dcfed6a19cc1bd3415 Depends-On: Ide70b5d8f67d8c8a87e3f16671f0f7fb72338b89 Depends-On: I8de48eb1fb4c8d321098ca54b9e21270edc7ac87 Depends-On: Ia5fda5d417b79189d048c8891b84d57331df1404 Implements: blueprint openstack-distribution-packages --- defaults/main.yml | 11 +++-- ...istribution-packages-bc0d1d606a362ffc.yaml | 7 ++++ tasks/main.yml | 30 ++++++------- tasks/octavia_install.yml | 42 +++++++++++++++++++ templates/octavia-uwsgi.ini.j2 | 2 + tox.ini | 7 +++- vars/debian.yml | 12 ++++++ vars/distro_install.yml | 4 ++ vars/redhat-7.yml | 20 +++++++++ vars/source_install.yml | 5 +++ zuul.d/jobs.yaml | 27 ++++++++++++ zuul.d/project.yaml | 3 ++ 12 files changed, 151 insertions(+), 19 deletions(-) create mode 100644 releasenotes/notes/openstack-distribution-packages-bc0d1d606a362ffc.yaml create mode 100644 tasks/octavia_install.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 1dbcccfa..7697daff 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -22,6 +22,9 @@ debug: False 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'])) }}" +# Set installation method. +octavia_install_method: "source" + ## Octavia standalone (v2) octavia_v2: True @@ -54,7 +57,7 @@ octavia_pip_install_args: "{{ pip_install_options | default('') }}" # Name of the virtual env to deploy into octavia_venv_tag: "{{ venv_tag | default('untagged') }}" -octavia_bin: "/openstack/venvs/octavia-{{ octavia_venv_tag }}/bin" +octavia_bin: "{{ _octavia_bin }}" octavia_clients_endpoint: internalURL @@ -177,14 +180,14 @@ octavia_services: service_name: octavia-api start_order: 4 init_config_overrides: "{{ octavia_api_init_overrides }}" - execstarts: "{{ octavia_bin }}/uwsgi --ini /etc/uwsgi/octavia-api.ini" - execreloads: "{{ octavia_bin }}/uwsgi --reload /var/run/octavia-api/octavia-api.pid" + execstarts: "{{ octavia_uwsgi_bin }}/uwsgi --ini /etc/uwsgi/octavia-api.ini" + execreloads: "{{ octavia_uwsgi_bin }}/uwsgi --reload /var/run/octavia-api/octavia-api.pid" wsgi_overrides: "{{ octavia_api_uwsgi_ini_overrides }}" wsgi_app: True wsgi_name: octavia-wsgi uwsgi_port: "{{ octavia_service_port }}" 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: group: octavia-worker service_name: octavia-worker diff --git a/releasenotes/notes/openstack-distribution-packages-bc0d1d606a362ffc.yaml b/releasenotes/notes/openstack-distribution-packages-bc0d1d606a362ffc.yaml new file mode 100644 index 00000000..e081cea1 --- /dev/null +++ b/releasenotes/notes/openstack-distribution-packages-bc0d1d606a362ffc.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 ``octavia_install_method`` + variable to ``distro``. diff --git a/tasks/main.yml b/tasks/main.yml index fb6a62e7..c5740f70 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -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.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 include_vars: "{{ item }}" with_first_found: @@ -38,24 +48,16 @@ tags: - octavia-config +- name: Gather variables for installation method + include_vars: "{{ octavia_install_method }}_install.yml" + tags: + - always + - include_tasks: octavia_pre_install.yml tags: - octavia-install -- 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 }}" +- include_tasks: octavia_install.yml tags: - octavia-install diff --git a/tasks/octavia_install.yml b/tasks/octavia_install.yml new file mode 100644 index 00000000..bd069a04 --- /dev/null +++ b/tasks/octavia_install.yml @@ -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' diff --git a/templates/octavia-uwsgi.ini.j2 b/templates/octavia-uwsgi.ini.j2 index f0203b61..28549d9d 100644 --- a/templates/octavia-uwsgi.ini.j2 +++ b/templates/octavia-uwsgi.ini.j2 @@ -2,7 +2,9 @@ uid = {{ octavia_system_user_name }} gid = {{ octavia_system_group_name }} +{% if octavia_install_method == 'source' %} virtualenv = /openstack/venvs/octavia-{{ octavia_venv_tag }} +{% endif %} wsgi-file = {{ octavia_bin }}/{{ item.wsgi_name }} http-socket = {{ item.uwsgi_bind_address }}:{{ item.uwsgi_port }} diff --git a/tox.ini b/tox.ini index e97de312..54299a99 100644 --- a/tox.ini +++ b/tox.ini @@ -93,6 +93,12 @@ basepython = python3 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:linters] basepython = python3 @@ -103,4 +109,3 @@ commands = {[testenv:ansible-lint]commands} {[testenv:ansible-syntax]commands} doc8 doc - diff --git a/vars/debian.yml b/vars/debian.yml index 2765b8d7..cd4e0a97 100644 --- a/vars/debian.yml +++ b/vars/debian.yml @@ -21,3 +21,15 @@ octavia_distro_packages: - iptables-persistent - libxml2-dev - 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' diff --git a/vars/distro_install.yml b/vars/distro_install.yml new file mode 100644 index 00000000..8ccc8375 --- /dev/null +++ b/vars/distro_install.yml @@ -0,0 +1,4 @@ +--- + +octavia_package_list: "{{ octavia_distro_packages + octavia_service_distro_packages + octavia_distro_openstack_clients_packages }}" +_octavia_bin: "/usr/bin" diff --git a/vars/redhat-7.yml b/vars/redhat-7.yml index 1919e556..3c3d7852 100644 --- a/vars/redhat-7.yml +++ b/vars/redhat-7.yml @@ -18,3 +18,23 @@ octavia_distro_packages: - iptables-services - libxml2-devel - 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' diff --git a/vars/source_install.yml b/vars/source_install.yml new file mode 100644 index 00000000..6fc48597 --- /dev/null +++ b/vars/source_install.yml @@ -0,0 +1,5 @@ +--- + +octavia_package_list: "{{ octavia_distro_packages }}" +_octavia_bin: "/openstack/venvs/octavia-{{ octavia_venv_tag }}/bin" +octavia_uwsgi_bin: "{{ _octavia_bin }}" diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index da4be9ff..6e226012 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -43,3 +43,30 @@ vars: action: deploy 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 diff --git a/zuul.d/project.yaml b/zuul.d/project.yaml index 1d7e80fa..aefdbb6c 100644 --- a/zuul.d/project.yaml +++ b/zuul.d/project.yaml @@ -23,6 +23,8 @@ - openstack-ansible-deploy-aio_metal_octavia-centos-7 - openstack-ansible-deploy-aio_metal_octavia-debian-stable - openstack-ansible-deploy-aio_metal_octavia-ubuntu-bionic + - openstack-ansible-deploy-aio_distro_metal_octaviav2-centos-7 + experimental: jobs: - 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-debian-stable - openstack-ansible-deploy-aio_metal_octavia-ubuntu-bionic + - openstack-ansible-deploy-aio_distro_metal_octaviav2-centos-7