Ensure distribution/architecture separation
Sometimes venvs are not very reusable across distributions and architectures, so to ensure this doesn't happen we store them in entirely different paths.
This commit is contained in:
parent
c3e210e9e7
commit
7a01d139ff
@ -61,8 +61,15 @@ venv_pip_install_args: ""
|
|||||||
venv_reuse_enable: yes
|
venv_reuse_enable: yes
|
||||||
|
|
||||||
# The path where a built venv should be stored on the
|
# The path where a built venv should be stored on the
|
||||||
# deployment host.
|
# deployment host. By default, ensure that the location
|
||||||
venv_reuse_download_path: "{{ lookup('env', 'HOME') | default('/opt', true) }}/cache"
|
# separates venvs per distribution and architecture to
|
||||||
|
# prevent re-use of venvs between them.
|
||||||
|
venv_reuse_download_path: "{{ lookup('env', 'HOME') | default('/opt', true) }}/cache/{{ venv_reuse_download_subfolder }}"
|
||||||
|
|
||||||
|
# NOTE(hwoarang): ansible_distribution may return a string with spaces
|
||||||
|
# such as "openSUSE Leap" so we need to replace the space with underscore
|
||||||
|
# in order to create a more sensible repo name for the distro.
|
||||||
|
venv_reuse_download_subfolder: "{{ (ansible_distribution | lower) | replace(' ', '_') }}-{{ ansible_distribution_version.split('.')[:2] | join('.') }}-{{ ansible_architecture | lower }}"
|
||||||
|
|
||||||
# The owner of the venv_reuse_download_path
|
# The owner of the venv_reuse_download_path
|
||||||
venv_reuse_download_path_owner: "{{ lookup('env', 'USER') | default('root', true) }}"
|
venv_reuse_download_path_owner: "{{ lookup('env', 'USER') | default('root', true) }}"
|
||||||
|
@ -105,9 +105,9 @@
|
|||||||
flat: yes
|
flat: yes
|
||||||
with_items:
|
with_items:
|
||||||
- src: "{{ venv_destination_path }}.tgz"
|
- src: "{{ venv_destination_path }}.tgz"
|
||||||
dest: "{{ venv_reuse_download_path }}/{{ venv_destination_path }}.tgz"
|
dest: "{{ venv_reuse_download_path }}/{{ venv_destination_path | basename }}.tgz"
|
||||||
- src: "{{ venv_destination_path }}.checksum"
|
- src: "{{ venv_destination_path }}.checksum"
|
||||||
dest: "{{ venv_reuse_download_path }}/{{ venv_destination_path }}.checksum"
|
dest: "{{ venv_reuse_download_path }}/{{ venv_destination_path | basename }}.checksum"
|
||||||
when:
|
when:
|
||||||
- _venv_package_build is mapping
|
- _venv_package_build is mapping
|
||||||
- _venv_package_build | changed
|
- _venv_package_build | changed
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
- name: Copy the venv checksum file to the target host
|
- name: Copy the venv checksum file to the target host
|
||||||
copy:
|
copy:
|
||||||
src: "{{ venv_reuse_download_path }}/{{ venv_destination_path }}.checksum"
|
src: "{{ venv_reuse_download_path }}/{{ venv_destination_path | basename }}.checksum"
|
||||||
dest: "{{ venv_destination_path | dirname }}"
|
dest: "{{ venv_destination_path | dirname }}"
|
||||||
register: _venv_checksum_copy
|
register: _venv_checksum_copy
|
||||||
- _src_venv_present.stat.exists | bool
|
- _src_venv_present.stat.exists | bool
|
||||||
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
- name: Unarchive pre-built venv
|
- name: Unarchive pre-built venv
|
||||||
unarchive:
|
unarchive:
|
||||||
src: "{{ venv_reuse_download_path }}/{{ venv_destination_path }}.tgz"
|
src: "{{ venv_reuse_download_path }}/{{ venv_destination_path | basename }}.tgz"
|
||||||
dest: "{{ venv_destination_path }}"
|
dest: "{{ venv_destination_path }}"
|
||||||
remote_src: no
|
remote_src: no
|
||||||
- _venv_checksum_copy is mapping
|
- _venv_checksum_copy is mapping
|
||||||
|
@ -21,9 +21,19 @@
|
|||||||
when:
|
when:
|
||||||
- venv_destination_path is not defined
|
- venv_destination_path is not defined
|
||||||
|
|
||||||
|
- name: Ensure that venv_reuse_download_path exists on the deployment host
|
||||||
|
file:
|
||||||
|
path: "{{ venv_reuse_download_path }}"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ venv_reuse_download_path_owner }}"
|
||||||
|
delegate_to: localhost
|
||||||
|
run_once: yes
|
||||||
|
when:
|
||||||
|
- venv_reuse_enable | bool
|
||||||
|
|
||||||
- name: Check if venv tgz is present on the deployment host
|
- name: Check if venv tgz is present on the deployment host
|
||||||
stat:
|
stat:
|
||||||
path: "{{ venv_reuse_download_path }}/{{ venv_destination_path }}.tgz"
|
path: "{{ venv_reuse_download_path }}/{{ venv_destination_path | basename }}.tgz"
|
||||||
get_attributes: no
|
get_attributes: no
|
||||||
get_checksum: no
|
get_checksum: no
|
||||||
get_md5: no
|
get_md5: no
|
||||||
@ -31,13 +41,5 @@
|
|||||||
register: _src_venv_present
|
register: _src_venv_present
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: yes
|
run_once: yes
|
||||||
|
|
||||||
- name: Ensure that venv_reuse_download_path exists on the deployment host
|
|
||||||
file:
|
|
||||||
path: "{{ venv_reuse_download_path }}/{{ venv_destination_path | dirname }}"
|
|
||||||
state: directory
|
|
||||||
owner: "{{ venv_reuse_download_path_owner }}"
|
|
||||||
delegate_to: localhost
|
|
||||||
run_once: yes
|
|
||||||
when:
|
when:
|
||||||
- venv_reuse_enable | bool
|
- venv_reuse_enable | bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user