Add venv build target hosts data structure
Currently python venv build targets run within the first repo server when > 0 repo servers are found or localhost however this is sub-optimal especially in environments with mixed architectures and operating systems. This change sets the python venv build to a repo server target node of the same os family and cpu arch when one is available otherwise the build process is performed on the target host, instead of falling back to localhost, which in many cases is a bastion server. Change-Id: Ibc30bb90ab1ce1a074d8e93a2d2b36f4dcefb90c Signed-off-by: cloudnull <kevin@cloudnull.com>
This commit is contained in:
parent
64019c5244
commit
ff0f3bf5f8
|
@ -86,7 +86,7 @@ venv_rebuild: no
|
|||
# subsequent venv builds on this host and others. When
|
||||
# this is the same as the target host, then we will not
|
||||
# bother building wheels.
|
||||
venv_build_host: "{{ ((groups['repo_all'] is defined) and (groups['repo_all'] | length > 0)) | ternary(groups.get('repo_all')[0], inventory_hostname) }}"
|
||||
venv_build_host: "{{ venv_build_targets[ansible_distribution_version][ansible_architecture] }}"
|
||||
|
||||
# The path for the wheel build venv.
|
||||
# This is the path where a venv will be created on the
|
||||
|
|
|
@ -31,3 +31,46 @@ _venv_build_base_distro_package_list:
|
|||
- gcc
|
||||
- gcc-c++
|
||||
- "{{ (venv_python_executable == 'python2') | ternary('python-devel', 'python3-devel') }}"
|
||||
|
||||
# Set the available build targets for all nodes within an environment.
|
||||
# build targets are grouped based on operating system and CPU
|
||||
# architecture.
|
||||
#
|
||||
# This is the data structure used to determine the build host.
|
||||
# venv_build_targets:
|
||||
# {
|
||||
# ansible_distribution_version: {
|
||||
# ansible_architecture: inventory_hostname
|
||||
# }
|
||||
# }
|
||||
#
|
||||
# Auto generation process:
|
||||
# * The automatic build targets will iterate over the group name
|
||||
# "repo_all" and if any target is found it will catagorize it
|
||||
# using the distro and cpu architecture criteria.
|
||||
# * If no group named "repo_all" is found the current inventory
|
||||
# hostname will be used as the only available build target.
|
||||
# * If no build target is found for matching the distro and cpu
|
||||
# criteria of the active inventory item, the generator will fall
|
||||
# back to using the active inventory host as the build target.
|
||||
#
|
||||
# NOTE: (cloudnull): While there may be multiple inventory items
|
||||
# that match a single distro and CPU architecture
|
||||
# type, only one build target will ever be used.
|
||||
# To make more than one build target effective,
|
||||
# deployers should be using a shared file system
|
||||
# for the repo servers.
|
||||
venv_build_targets: |-
|
||||
{% set targets = {
|
||||
(ansible_distribution_version | string): {
|
||||
(ansible_architecture | string): (inventory_hostname | string)
|
||||
}
|
||||
}
|
||||
%}
|
||||
{% for item in (groups['repo_all'] | default([inventory_hostname])) %}
|
||||
{% set distro = hostvars[item]['ansible_distribution_version'] %}
|
||||
{% set arch = hostvars[item]['ansible_architecture'] %}
|
||||
{% set target_item = {(arch | string): (item | string)} %}
|
||||
{% set _ = targets.__setitem__(distro, target_item) %}
|
||||
{% endfor %}
|
||||
{{ targets }}
|
||||
|
|
Loading…
Reference in New Issue