Merge "Use a common python build/install role"
This commit is contained in:
commit
1c5627f37e
@ -50,8 +50,19 @@ nova_developer_constraints:
|
|||||||
- "git+{{ nova_git_repo }}@{{ nova_git_install_branch }}#egg=nova"
|
- "git+{{ nova_git_repo }}@{{ nova_git_install_branch }}#egg=nova"
|
||||||
- "git+{{ nova_lxd_git_repo }}@{{ nova_lxd_git_install_branch }}#egg=nova-lxd"
|
- "git+{{ nova_lxd_git_repo }}@{{ nova_lxd_git_install_branch }}#egg=nova-lxd"
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
nova_pip_install_args: >-
|
||||||
|
{{ nova_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
|
# Name of the virtual env to deploy into
|
||||||
nova_venv_tag: untagged
|
nova_venv_tag: "{{ venv_tag | default('untagged') }}"
|
||||||
nova_bin: "{{ _nova_bin }}"
|
nova_bin: "{{ _nova_bin }}"
|
||||||
|
|
||||||
# venv_download, even when true, will use the fallback method of building the
|
# venv_download, even when true, will use the fallback method of building the
|
||||||
|
@ -31,7 +31,9 @@
|
|||||||
until: _stop is success
|
until: _stop is success
|
||||||
retries: 5
|
retries: 5
|
||||||
delay: 2
|
delay: 2
|
||||||
listen: "Restart nova services"
|
listen:
|
||||||
|
- "Restart nova services"
|
||||||
|
- "venv changed"
|
||||||
|
|
||||||
# Note (odyssey4me):
|
# Note (odyssey4me):
|
||||||
# The policy.json file is currently read continually by the services
|
# The policy.json file is currently read continually by the services
|
||||||
@ -49,7 +51,9 @@
|
|||||||
group: "{{ nova_system_group_name }}"
|
group: "{{ nova_system_group_name }}"
|
||||||
mode: "0640"
|
mode: "0640"
|
||||||
remote_src: yes
|
remote_src: yes
|
||||||
listen: "Restart nova services"
|
listen:
|
||||||
|
- "Restart nova services"
|
||||||
|
- "venv changed"
|
||||||
|
|
||||||
- name: Start services
|
- name: Start services
|
||||||
service:
|
service:
|
||||||
@ -62,7 +66,9 @@
|
|||||||
until: _start is success
|
until: _start is success
|
||||||
retries: 5
|
retries: 5
|
||||||
delay: 2
|
delay: 2
|
||||||
listen: "Restart nova services"
|
listen:
|
||||||
|
- "Restart nova services"
|
||||||
|
- "venv changed"
|
||||||
|
|
||||||
- meta: noop
|
- meta: noop
|
||||||
listen: Manage LB
|
listen: Manage LB
|
||||||
|
@ -72,10 +72,7 @@
|
|||||||
- name: "need_online_data_migrations"
|
- name: "need_online_data_migrations"
|
||||||
state: "True"
|
state: "True"
|
||||||
when:
|
when:
|
||||||
- (nova_install_method == 'source' and
|
- (install_packages | changed) or
|
||||||
((nova_get_venv | changed) or
|
|
||||||
(nova_venv_dir | changed))) or
|
|
||||||
(install_packages | changed) or
|
|
||||||
(ansible_local is not defined) or
|
(ansible_local is not defined) or
|
||||||
('openstack_ansible' not in ansible_local) or
|
('openstack_ansible' not in ansible_local) or
|
||||||
('nova' not in ansible_local['openstack_ansible']) or
|
('nova' not in ansible_local['openstack_ansible']) or
|
||||||
|
@ -13,6 +13,12 @@
|
|||||||
# 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.
|
||||||
|
|
||||||
|
# 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
|
- name: Create developer mode constraint file
|
||||||
copy:
|
copy:
|
||||||
dest: "/opt/developer-pip-constraints.txt"
|
dest: "/opt/developer-pip-constraints.txt"
|
||||||
@ -22,122 +28,30 @@
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
when:
|
when:
|
||||||
- nova_developer_mode | bool
|
- nova_developer_mode | bool
|
||||||
tags:
|
|
||||||
- nova-pip-packages
|
|
||||||
|
|
||||||
- name: Retrieve checksum for venv download
|
- name: Ensure remote wheel building is disabled in developer mode
|
||||||
uri:
|
set_fact:
|
||||||
url: "{{ nova_venv_download_url | replace('tgz', 'checksum') }}"
|
venv_build_host: "{{ ansible_hostname }}"
|
||||||
return_content: yes
|
|
||||||
register: nova_venv_checksum
|
|
||||||
when:
|
when:
|
||||||
- nova_venv_download | bool
|
- nova_developer_mode | bool
|
||||||
tags:
|
|
||||||
- nova-pip-packages
|
|
||||||
- always
|
|
||||||
|
|
||||||
- name: Attempt venv download
|
- name: Install the python venv
|
||||||
get_url:
|
include_role:
|
||||||
url: "{{ nova_venv_download_url }}"
|
name: "python_venv_build"
|
||||||
dest: "/var/cache/{{ nova_venv_download_url | basename }}"
|
private: yes
|
||||||
checksum: "sha1:{{ nova_venv_checksum.content | trim }}"
|
vars:
|
||||||
register: nova_get_venv
|
venv_build_distro_package_list: "{{ nova_devel_distro_packages }}"
|
||||||
when:
|
venv_install_destination_path: "{{ nova_bin | dirname }}"
|
||||||
- nova_venv_download | bool
|
venv_install_distro_package_list: "{{ nova_distro_packages }}"
|
||||||
tags:
|
venv_pip_install_args: "{{ nova_pip_install_args }}"
|
||||||
- nova-pip-packages
|
venv_pip_packages: "{{ nova_pip_packages }}"
|
||||||
- always
|
venv_facts_when_changed:
|
||||||
|
- section: "nova"
|
||||||
- name: Remove existing venv
|
option: "need_service_restart"
|
||||||
file:
|
value: "True"
|
||||||
path: "{{ nova_bin | dirname }}"
|
- section: "nova"
|
||||||
state: absent
|
option: "need_online_data_migrations"
|
||||||
when:
|
value: "True"
|
||||||
- nova_get_venv is changed
|
- section: "nova"
|
||||||
tags:
|
option: "venv_tag"
|
||||||
- nova-pip-packages
|
value: "{{ nova_venv_tag }}"
|
||||||
|
|
||||||
- name: Create nova venv dir
|
|
||||||
file:
|
|
||||||
path: "{{ nova_bin | dirname }}"
|
|
||||||
state: directory
|
|
||||||
register: nova_venv_dir
|
|
||||||
when:
|
|
||||||
- nova_get_venv is changed
|
|
||||||
tags:
|
|
||||||
- nova-pip-packages
|
|
||||||
|
|
||||||
- name: Unarchive pre-built venv
|
|
||||||
unarchive:
|
|
||||||
src: "/var/cache/{{ nova_venv_download_url | basename }}"
|
|
||||||
dest: "{{ nova_bin | dirname }}"
|
|
||||||
copy: "no"
|
|
||||||
when:
|
|
||||||
- nova_get_venv is changed
|
|
||||||
notify:
|
|
||||||
- Manage LB
|
|
||||||
- Restart nova services
|
|
||||||
tags:
|
|
||||||
- nova-pip-packages
|
|
||||||
|
|
||||||
- name: Install pip packages
|
|
||||||
pip:
|
|
||||||
name: "{{ nova_pip_packages }}"
|
|
||||||
state: "{{ nova_pip_package_state }}"
|
|
||||||
virtualenv: "{{ nova_bin | dirname }}"
|
|
||||||
virtualenv_site_packages: "no"
|
|
||||||
extra_args: >-
|
|
||||||
{{ nova_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:
|
|
||||||
- nova_get_venv | failed or nova_get_venv | skipped
|
|
||||||
notify:
|
|
||||||
- Manage LB
|
|
||||||
- Restart nova services
|
|
||||||
tags:
|
|
||||||
- nova-pip-packages
|
|
||||||
|
|
||||||
- name: Remove python from path first (CentOS, openSUSE)
|
|
||||||
file:
|
|
||||||
path: "{{ nova_bin | dirname }}/bin/python2.7"
|
|
||||||
state: "absent"
|
|
||||||
when:
|
|
||||||
- ansible_pkg_mgr in ['yum', 'dnf', 'zypper']
|
|
||||||
- nova_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: Update virtualenv path
|
|
||||||
shell: |
|
|
||||||
set -o errexit
|
|
||||||
find {{ nova_bin }} -name \*.pyc -delete
|
|
||||||
if test -d {{ nova_bin }}/__pycache__; then rmdir {{ nova_bin }}/__pycache__; fi
|
|
||||||
sed -si '1s/^.*python.*$/#!{{ nova_bin | replace ('/','\/') }}\/python/' {{ nova_bin }}/*
|
|
||||||
virtualenv {{ nova_bin | dirname }} \
|
|
||||||
{{ (ansible_pkg_mgr == 'apt') | ternary('--always-copy', '') }} \
|
|
||||||
--no-pip \
|
|
||||||
--no-setuptools \
|
|
||||||
--no-wheel
|
|
||||||
when:
|
|
||||||
- nova_get_venv is changed
|
|
||||||
tags:
|
|
||||||
- skip_ansible_lint
|
|
||||||
- nova-pip-packages
|
|
||||||
- Restart nova services
|
|
||||||
|
|
||||||
- name: Record the venv tag deployed
|
|
||||||
ini_file:
|
|
||||||
dest: "/etc/ansible/facts.d/openstack_ansible.fact"
|
|
||||||
section: nova
|
|
||||||
option: venv_tag
|
|
||||||
value: "{{ nova_venv_tag }}"
|
|
||||||
|
Loading…
Reference in New Issue
Block a user