openstack-ansible/playbooks/utility-install.yml
Jesse Pretorius b95c0e1e22 Use a common python build/install role
In order to radically simplify how we prepare the service
venvs, we use a common role to do the wheel builds and the
venv preparation. This makes the process far simpler to
understand, because the role does its own building and
installing. It also reduces the code maintenance burden,
because instead of duplicating the build processes in the
repo_build role and the service role - we only have it all
done in a single place.

Given that the role now handles everything, and has sensible
defaults, we can remove the *_venv_tag and *_venv_download_url
in group_vars.

This is by no means the final stop in the simplification
process, but it is a step forward. The will be work to follow
which:

1. Changes how we define the versions of each service we wish
   to install. Currently this requires the use of the py_pkgs
   plugin, but we'd like to eliminate that to simplify the
   mechanism to something more intuitive.
2. Changes how we set the pip install arguments for the venv
   build. Right now the repo_build consolidates all constraints
   into a single set. That code is complex, difficult to
   understand and prohibits multi-series deployments.
3. Changes how we configure pip. Given that we no longer do
   pip installs onto the host, and only use venvs, we do not
   need to place pip.conf in a global location. We can explore
   other options, including perhaps not placing pip.conf at all.
4. Removes the repo_build process entirely. Once the roles are
   doing everything that's required, the repo_build process will
   be redundant and can be removed.

Depends-On: https://review.openstack.org/557039
Depends-On: https://review.openstack.org/557041
Depends-On: https://review.openstack.org/557042
Depends-On: https://review.openstack.org/557043
Depends-On: https://review.openstack.org/557047
Depends-On: https://review.openstack.org/557049
Depends-On: https://review.openstack.org/557050
Depends-On: https://review.openstack.org/557052
Depends-On: https://review.openstack.org/557053
Depends-On: https://review.openstack.org/557055
Depends-On: https://review.openstack.org/557059
Depends-On: https://review.openstack.org/557061
Depends-On: https://review.openstack.org/567692
Depends-On: https://review.openstack.org/599238
Depends-On: https://review.openstack.org/599240
Depends-On: https://review.openstack.org/599244
Depends-On: https://review.openstack.org/599247
Depends-On: https://review.openstack.org/599256
Depends-On: https://review.openstack.org/599434
Depends-On: https://review.openstack.org/599437
Change-Id: Ic31bd1c9f1c3eea61af50210d93aa96f9c797d92
2018-09-03 18:28:53 +01:00

124 lines
4.3 KiB
YAML

---
# 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: Setup the utility location(s)
hosts: utility_all
user: root
gather_facts: "{{ osa_gather_facts | default(True) }}"
environment: "{{ deployment_environment_variables | default({}) }}"
vars_files:
- "defaults/{{ install_method }}_install.yml"
tags:
- utility
pre_tasks:
- include: "common-tasks/os-{{ container_tech | default('lxc') }}-container-setup.yml"
static: no
when: not is_metal
- include: common-tasks/os-log-dir-setup.yml
vars:
log_dirs:
- src: "/openstack/log/{{ inventory_hostname }}-utility"
dest: "/var/log/utility"
- include: common-tasks/unbound-clients.yml
static: no
when:
- hostvars['localhost']['resolvconf_enabled'] | bool
- name: Create log directory (not is_metal)
file:
dest: "/var/log/utility"
state: "directory"
force: "yes"
when: not is_metal | bool
roles:
- role: "galera_client"
- role: "openstack_openrc"
tags:
- openrc
post_tasks:
- name: Add OpenStack client to distro packages
set_fact:
utility_distro_packages: "{{ (utility_distro_packages | default([])) + utility_distro_openstack_clients_packages }}"
when: install_method == "distro"
- name: Install distro packages
package:
name: "{{ utility_distro_packages | default([]) }}"
state: "{{ utility_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(cache_timeout, omit) }}"
- name: Distribute private ssh key
copy:
content: "{{ utility_ssh_private_key }}"
dest: /root/.ssh/id_rsa
mode: 0600
owner: root
group: root
when: utility_ssh_private_key is defined
- name: Install openstack clients (source-based install)
when:
- install_method == "source"
block:
- name: Get list of repo packages
uri:
url: "{{ repo_release_path }}/requirements_absolute_requirements.txt"
return_content: yes
register: _abs_reqs
run_once: true
tags:
- always
- name: Derive the list of openstack clients
set_fact:
_openstack_client_list: >-
{%- set package_list = [] %}
{%- for l in _abs_reqs.content.split('\n') %}
{%- if (l is match('^python_.*client==.*$')) or (l is match('^(aodh|gnocchi)client==.*$')) %}
{%- set _ = package_list.append(l | regex_replace('==.*$', '')) %}
{%- endif %}
{%- endfor %}
{{- package_list }}
run_once: true
tags:
- always
- name: Install the python venv
include_role:
name: "python_venv_build"
private: yes
vars:
venv_install_destination_path: "{{ utility_venv_bin | dirname }}"
venv_pip_install_args: >-
{{ (pip_install_upper_constraints is defined) | ternary('--constraint ' + pip_install_upper_constraints | default(''),'') }}
{{ pip_install_options | default('') }}
venv_pip_packages: "{{ _openstack_client_list | union(utility_pip_packages) }}"
- name: Create symlinks for openstack clients
shell: |
{% set _bin_name = item | regex_replace('^(?:python_)?(\w*)(?:client)$', '\\1') %}
if [[ -e "{{ utility_venv_bin }}/{{ _bin_name }}" ]]; then
ln -sfn {{ utility_venv_bin }}/{{ _bin_name }} /usr/local/bin/{{ _bin_name }}
fi
args:
executable: /bin/bash
with_items: "{{ _openstack_client_list }}"