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