Provide ability to override upper-constraints

This patch adds a new list variable which allows a deployer to
override OpenStack's upper-constraints for the repo build
process.

Change-Id: I46ba9345a85c43f2a1f24ea1819132e7474e6909
Co-Authored-By: Jimmy McCrory <jimmy.mccrory@gmail.com>
This commit is contained in:
Jesse Pretorius 2016-07-29 09:12:21 +01:00
parent 4622724733
commit 22b14ceb7f
5 changed files with 47 additions and 5 deletions

View File

@ -13,8 +13,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.
# Use OpenStack's upper-constraints
repo_build_use_upper_constraints: true
# A list of overrides to apply to OpenStack's upper constraints
# Use these with caution as you're implementing a change to the
# package set which OpenStack has tested its releases with!
repo_build_upper_constraints_overrides: []
repo_build_service_user_name: "nginx"
repo_build_global_links_path: "/var/www/repo/links"

View File

@ -0,0 +1,6 @@
---
features:
- The ``repo_build`` role now provides the ability to override the
upper-constraints applied which are sourced from OpenStack. The
variable ``repo_build_upper_constraints_overrides`` can be
populated with a list of upper constraints.

View File

@ -39,7 +39,7 @@
- repo-get-upper-constraints
- repo-build-constraints-file
- name: Set upper constraints
- name: Decode the upper constraints content
set_fact:
_upper_constraints: "{{ slurp_upper_constraints.content | b64decode | splitlines }}"
when: slurp_upper_constraints | success
@ -47,10 +47,19 @@
- repo-set-constraints
- repo-build-constraints-file
- name: Set upper constraints
- name: Normalise the upper constraints
set_fact:
upper_constraints: "{{ local_requirement_normalized | pip_constraint_update(_upper_constraints) }}"
when: slurp_upper_constraints | success
tags:
- repo-set-constraints
- repo-build-constraints-file
- name: Apply the upper constraint overrides
set_fact:
upper_constraints: "{{ upper_constraints | pip_constraint_update(repo_build_upper_constraints_overrides) }}"
when: repo_build_upper_constraints_overrides | length > 0
tags:
- repo-set-constraints
- repo-build-constraints-file

View File

@ -69,13 +69,28 @@
{%- for package in slurp_upper_constraints.content | b64decode | splitlines %}
{%- set name = package | regex_replace('===.*$','') %}
{%- set version = package | regex_replace('^.*===','') %}
{%- set _ = constraints.update({name:version}) %}
{%- set _ = constraints.update({name: version}) %}
{%- endfor %}
{{- constraints -}}
- name: Set fact for upper constraints override
set_fact:
upper_constraints_override_list: >
{%- set override_packages = [] %}
{%- for override in repo_build_upper_constraints_overrides %}
{%- set name = override | regex_replace('(>=|<=|>|<|==|~=|!=).*$','') %}
{%- set _ = override_packages.append(name) %}
{%- endfor %}
{{- override_packages -}}
- name: Ensure that requirements constraints is applying upper constraints
assert:
that: requirements_constraints_content.find( "{{ item.key }}<={{item.value}}" ) != -1
that: requirements_constraints_content.find( "{{ item.key }}<={{ item.value }}" ) != -1
with_dict: upper_constraints_dict
when: requirements_constraints_content.find(item.key) != -1
when:
- item.key not in upper_constraints_override_list
- requirements_constraints_content.find(item.key) != -1
- name: Ensure that upper constraints overrides are applied
assert:
that: requirements_constraints_content.find( "{{ item }}" ) != -1
with_items: "{{ repo_build_upper_constraints_overrides }}"
vars_files:
- test-vars.yml

View File

@ -16,6 +16,12 @@
openstack_release: testing
repo_build_release_tag: "{{ openstack_release }}"
galera_client_drop_config_file: false
# Test data input for upper constraints validation
repo_build_upper_constraints_overrides:
- elasticsearch<2.1.0
# Test data output from the py_pkgs lookup
local_packages:
results:
-