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. We also change the role venv tag var to use the integrated build's common venv tag so that we can remove the role's venv tag in group_vars in the integrated build. This reduces memory consumption and also reduces the duplication. 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. Replaces 'developer mode' with an equivalent mechanism that uses the common role and is simpler to understand. We will also simplify the provisioning of pip install arguments when doing this. 2. Simplifies the installation of optional pip packages. Right now it's more complicated than it needs to be due to us needing to keep the py_pkgs plugin working in the integrated build. 3. Deduplicates the distro package installs. Right now the role installs the distro packages twice - just before building the venv, and during the python_venv_build role execution. Depends-On: https://review.openstack.org/598957 Change-Id: Ica126c4ae20d2a7972a9309147cf6db902343bbf Implements: blueprint python-build-install-simplification Signed-off-by: Jesse Pretorius <jesse.pretorius@rackspace.co.uk>
This commit is contained in:
parent
1a28d7af4e
commit
7d3a797c2c
@ -32,8 +32,19 @@ cinder_developer_mode: false
|
||||
cinder_developer_constraints:
|
||||
- "git+{{ cinder_git_repo }}@{{ cinder_git_install_branch }}#egg=cinder"
|
||||
|
||||
# TODO(odyssey4me):
|
||||
# This can be simplified once all the roles are using
|
||||
# python_venv_build. We can then switch to using a
|
||||
# set of constraints in pip.conf inside the venv,
|
||||
# perhaps prepared by giving a giving a list of
|
||||
# constraints to the role.
|
||||
cinder_pip_install_args: >-
|
||||
{{ cinder_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('') }}
|
||||
|
||||
# Name of the virtual env to deploy into
|
||||
cinder_venv_tag: untagged
|
||||
cinder_venv_tag: "{{ venv_tag | default('untagged') }}"
|
||||
cinder_bin: "{{ _cinder_bin }}"
|
||||
|
||||
# venv_download, even when true, will use the fallback method of building the
|
||||
|
@ -24,7 +24,9 @@
|
||||
until: _stop is success
|
||||
retries: 5
|
||||
delay: 2
|
||||
listen: Restart cinder services
|
||||
listen:
|
||||
- "Restart cinder services"
|
||||
- "venv changed"
|
||||
|
||||
# Note (odyssey4me):
|
||||
# The policy.json file is currently read continually by the services
|
||||
@ -42,7 +44,9 @@
|
||||
group: "{{ cinder_system_group_name }}"
|
||||
mode: "0640"
|
||||
remote_src: yes
|
||||
listen: Restart cinder services
|
||||
listen:
|
||||
- "Restart cinder services"
|
||||
- "venv changed"
|
||||
|
||||
- name: Start services
|
||||
service:
|
||||
@ -55,7 +59,9 @@
|
||||
until: _start is success
|
||||
retries: 5
|
||||
delay: 2
|
||||
listen: Restart cinder services
|
||||
listen:
|
||||
- "Restart cinder services"
|
||||
- "venv changed"
|
||||
|
||||
- name: Ensure tgt service restarted
|
||||
service:
|
||||
|
@ -13,6 +13,12 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# TODO(odyssey4me):
|
||||
# This can be simplified once all the roles are using
|
||||
# python_venv_build. We can then switch to using a
|
||||
# set of constraints in pip.conf inside the venv,
|
||||
# perhaps prepared by giving a giving a list of
|
||||
# constraints to the role.
|
||||
- name: Create developer mode constraint file
|
||||
copy:
|
||||
dest: "/opt/developer-pip-constraints.txt"
|
||||
@ -22,62 +28,32 @@
|
||||
{% endfor %}
|
||||
when: cinder_developer_mode | bool
|
||||
|
||||
- name: Retrieve checksum for venv download
|
||||
uri:
|
||||
url: "{{ cinder_venv_download_url | replace('tgz', 'checksum') }}"
|
||||
return_content: yes
|
||||
register: cinder_venv_checksum
|
||||
when: cinder_venv_download | bool
|
||||
- name: Ensure remote wheel building is disabled in developer mode
|
||||
set_fact:
|
||||
venv_build_host: "{{ ansible_hostname }}"
|
||||
when:
|
||||
- cinder_developer_mode | bool
|
||||
|
||||
- name: Attempt venv download
|
||||
get_url:
|
||||
url: "{{ cinder_venv_download_url }}"
|
||||
dest: "/var/cache/{{ cinder_venv_download_url | basename }}"
|
||||
checksum: "sha1:{{ cinder_venv_checksum.content | trim }}"
|
||||
register: cinder_get_venv
|
||||
when: cinder_venv_download | bool
|
||||
|
||||
- name: Remove existing venv
|
||||
file:
|
||||
path: "{{ cinder_bin | dirname }}"
|
||||
state: absent
|
||||
when: cinder_get_venv is changed
|
||||
|
||||
- name: Create cinder venv dir
|
||||
file:
|
||||
path: "{{ cinder_bin | dirname }}"
|
||||
state: directory
|
||||
register: cinder_venv_dir
|
||||
when: cinder_get_venv is changed
|
||||
|
||||
- name: Unarchive pre-built venv
|
||||
unarchive:
|
||||
src: "/var/cache/{{ cinder_venv_download_url | basename }}"
|
||||
dest: "{{ cinder_bin | dirname }}"
|
||||
copy: "no"
|
||||
when: cinder_get_venv is changed
|
||||
notify:
|
||||
- Manage LB
|
||||
- Restart cinder services
|
||||
|
||||
- name: Install pip packages
|
||||
pip:
|
||||
name: "{{ cinder_pip_packages }}"
|
||||
state: "{{ cinder_pip_package_state }}"
|
||||
virtualenv: "{{ cinder_bin | dirname }}"
|
||||
virtualenv_site_packages: "no"
|
||||
extra_args: >-
|
||||
{{ cinder_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 is success
|
||||
retries: 5
|
||||
delay: 2
|
||||
when: cinder_get_venv | failed or cinder_get_venv | skipped
|
||||
notify:
|
||||
- Manage LB
|
||||
- Restart cinder services
|
||||
- name: Install the python venv
|
||||
include_role:
|
||||
name: "python_venv_build"
|
||||
private: yes
|
||||
vars:
|
||||
venv_build_distro_package_list: "{{ cinder_devel_distro_packages }}"
|
||||
venv_install_destination_path: "{{ cinder_bin | dirname }}"
|
||||
venv_install_distro_package_list: "{{ cinder_distro_packages }}"
|
||||
venv_pip_install_args: "{{ cinder_pip_install_args }}"
|
||||
venv_pip_packages: "{{ cinder_pip_packages }}"
|
||||
venv_facts_when_changed:
|
||||
- section: "cinder"
|
||||
option: "need_service_restart"
|
||||
value: True
|
||||
- section: "cinder"
|
||||
option: "need_online_data_migrations"
|
||||
value: True
|
||||
- section: "cinder"
|
||||
option: "venv_tag"
|
||||
value: "{{ cinder_venv_tag }}"
|
||||
|
||||
- name: Copy cinder rootwrap filters
|
||||
command: >-
|
||||
@ -91,52 +67,3 @@
|
||||
notify:
|
||||
- Manage LB
|
||||
- Restart cinder services
|
||||
|
||||
- name: Remove python from path first (CentOS, openSUSE)
|
||||
file:
|
||||
path: "{{ cinder_bin | dirname }}/bin/python2.7"
|
||||
state: "absent"
|
||||
when:
|
||||
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
|
||||
- cinder_get_venv is 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: Reset virtualenv and update its paths
|
||||
shell: |
|
||||
find {{ cinder_bin }} -name \*.pyc -delete
|
||||
sed -si '1s/^.*python.*$/#!{{ cinder_bin | replace ('/','\/') }}\/python/' {{ cinder_bin }}/*
|
||||
virtualenv {{ cinder_bin | dirname }} \
|
||||
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} \
|
||||
--no-pip \
|
||||
--no-setuptools \
|
||||
--no-wheel
|
||||
when: cinder_get_venv is changed
|
||||
tags:
|
||||
- skip_ansible_lint
|
||||
|
||||
- name: Initialise the upgrade facts
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
section: cinder
|
||||
option: "{{ item }}"
|
||||
value: true
|
||||
with_items:
|
||||
- "need_online_data_migrations"
|
||||
- "need_service_restart"
|
||||
when: (cinder_get_venv | changed) or
|
||||
(cinder_venv_dir | changed) or
|
||||
('need_online_data_migrations' not in ansible_local['openstack_ansible']['cinder']) or
|
||||
('need_service_restart' not in ansible_local['openstack_ansible']['cinder'])
|
||||
|
||||
- name: Record the venv tag deployed
|
||||
ini_file:
|
||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
||||
section: cinder
|
||||
option: venv_tag
|
||||
value: "{{ cinder_venv_tag }}"
|
||||
|
@ -27,7 +27,7 @@ cinder_package_list: |-
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if cinder_developer_mode | bool %}
|
||||
{% set _ = packages.extend(cinder_developer_mode_distro_packages) %}
|
||||
{% set _ = packages.extend(cinder_devel_distro_packages) %}
|
||||
{% endif %}
|
||||
{{ packages }}
|
||||
|
||||
|
@ -37,7 +37,7 @@ cinder_service_distro_packages:
|
||||
- uwsgi
|
||||
- uwsgi-plugin-python
|
||||
|
||||
cinder_developer_mode_distro_packages:
|
||||
cinder_devel_distro_packages:
|
||||
- git
|
||||
- systemd-devel
|
||||
|
||||
|
@ -27,7 +27,7 @@ cinder_package_list: |-
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if cinder_developer_mode | bool %}
|
||||
{% set _ = packages.extend(cinder_developer_mode_distro_packages) %}
|
||||
{% set _ = packages.extend(cinder_devel_distro_packages) %}
|
||||
{% endif %}
|
||||
{{ packages }}
|
||||
|
||||
|
@ -42,7 +42,7 @@ cinder_service_distro_packages:
|
||||
- uwsgi
|
||||
- uwsgi-python
|
||||
|
||||
cinder_developer_mode_distro_packages:
|
||||
cinder_devel_distro_packages:
|
||||
- git-core
|
||||
- pkg-config
|
||||
- systemd-devel
|
||||
|
@ -48,7 +48,7 @@ cinder_service_distro_packages:
|
||||
- uwsgi
|
||||
- uwsgi-plugin-python
|
||||
|
||||
cinder_developer_mode_distro_packages:
|
||||
cinder_devel_distro_packages:
|
||||
- build-essential
|
||||
- git-core
|
||||
- libsystemd-dev
|
||||
|
Loading…
x
Reference in New Issue
Block a user