Skip to content

Commit c9ec3c5

Browse files
author
scrungus
committed
semver included in key name, dependencies + helm chart version injected
1 parent 730bc64 commit c9ec3c5

File tree

8 files changed

+72
-12
lines changed

8 files changed

+72
-12
lines changed

examples/templates/images.j2

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,14 @@
1717
# List of Kubernetes images. Format is as required by the stackhpc.os-images role.
1818
kubernetes_images:
1919
{% if matching_images is defined and matching_temps | length > 0 %}
20+
# Old Images
2021
{% for item in matching_images %}
2122
{% if (item.value.name | replace('_', '-')) not in (new_template_data | map(attribute='value.name')) %}
2223
- "{{ '{{ ' + item.key + ' }}' }}"
2324
{% endif %}
2425
{% endfor %}
2526
{% endif %}
27+
# New Images
2628
{% for item in new_template_data %}
2729
- "{{ '{{ ' + (item.value.name | replace('-', '_')) | replace('.', '_') + ' }}' }}"
2830
{% endfor %}

examples/templates/old-templates.j2

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
###############################################################################
33
# Old magnum templates - hide until out of use
44

5+
{% set versions_to_check = new_template_data | map(attribute='value.kubernetes_version') | map('replace', '.', '-') %}
6+
{% set keys_and_versions = new_template_data | map(attribute='key') | zip(versions_to_check) %}
57
{% for item in matching_temps %}
6-
{% if (item.key | replace('_', '-')) not in new_template_data | map(attribute='key') %}
8+
{% if (item.key | replace('_', '-')) not in keys_and_versions | map('join', '-') %}
79
{{ item.key }}:
810
{% for key, value in item.value.items() %}
911
{% if value is mapping %}

examples/templates/templates.j2

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Configuration of Magnum container clusters.
33

44
{% for item in new_template_data %}
5-
{{ item.key | replace('-', '_') }}:
5+
{{ item.key | replace('-', '_') }}_{{ item.value.kubernetes_version | replace('.', '_') }}:
66
labels:
77
monitoring_enabled: "True"
88
kube_dashboard_enabled: "True"
@@ -25,12 +25,16 @@
2525
# stackhpc.os-container-clusters role.
2626
openstack_container_clusters_templates:
2727
{% if matching_temps is defined and matching_temps | length > 0 %}
28+
# Old Templates
29+
{% set versions_to_check = new_template_data | map(attribute='value.kubernetes_version') | map('replace', '.', '-') %}
30+
{% set keys_and_versions = new_template_data | map(attribute='key') | zip(versions_to_check) %}
2831
{% for item in matching_temps %}
29-
{% if (item.key | replace('_', '-')) not in (new_template_data | map(attribute='key')) %}
32+
{% if (item.key | replace('_', '-')) not in keys_and_versions | map('join', '-') %}
3033
- "{{ '{{ ' + item.key + ' }}' }}"
3134
{% endif %}
3235
{% endfor %}
3336
{% endif %}
37+
# New Templates
3438
{% for item in new_template_data %}
35-
- "{{ '{{ ' + (item.key| replace('-', '_')) + ' }}' }}"
39+
- "{{ '{{ ' + (item.key| replace('-', '_')) + '_' + (item.value.kubernetes_version | replace('.', '_')) + ' }}' }}"
3640
{% endfor %}

requirements.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
roles:
33
- name: stackhpc.os-flavors
44
- name: stackhpc.os-images
5+
src: https://github.com/stackhpc/ansible-role-os-images.git
6+
version: 1b076df89c6f0ac8e77b03572aa398aab89b7e23
57
- name: stackhpc.os-networks
68
- name: stackhpc.os-projects
79
- name: stackhpc.os_host_aggregates
810
- name: stackhpc.os-container-clusters
11+
src: https://github.com/stackhpc/ansible-role-os-container-clusters.git
12+
version: 67c098434dad6b02087b76286b5d23b411e24917
913

1014
collections:
1115
- name: openstack.cloud

tools/merge_config/bin/ensure_venv

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
# This script creates a virtualenv (if not already in one) and installs the required dependencies
33
#####
44

5+
CONFIG_ROOT="$(dirname $(dirname $(dirname $(dirname $(realpath ${BASH_SOURCE[0]:-${(%):-%x}})))))"
6+
57
if [[ "$VIRTUAL_ENV" == "" ]]; then
68
# Check python version
79
# NOTE: Python 3.8 or newer is required for ansible 2.12
@@ -10,9 +12,9 @@ if [[ "$VIRTUAL_ENV" == "" ]]; then
1012
PY_MINOR=8
1113
version_check() {
1214
python3 <<EOF
13-
import sys
14-
if sys.version_info[0] < $PY_MAJOR or sys.version_info[1] < $PY_MINOR:
15-
sys.exit(1)
15+
import sys
16+
if sys.version_info[0] < $PY_MAJOR or sys.version_info[1] < $PY_MINOR:
17+
sys.exit(1)
1618
EOF
1719
}
1820

@@ -22,7 +24,7 @@ EOF
2224
exit 1
2325
fi
2426

25-
VENV="$CONFIG_ROOT/tools/merge_magnum_config/.venv"
27+
VENV="$CONFIG_ROOT/tools/merge_config/.venv"
2628
if [ ! -d "$VENV" ]; then
2729
echo "Creating virtual environment at $VENV"
2830
python3 -m venv "$VENV"
@@ -32,8 +34,6 @@ else
3234
VENV=$VIRTUAL_ENV
3335
fi
3436

35-
CONFIG_ROOT="$(dirname $(dirname $(dirname $(dirname $(realpath ${BASH_SOURCE[0]:-${(%):-%x}})))))"
36-
3737
echo "Upgrading pip"
3838
"$VENV/bin/python" -m pip install -U pip
3939

tools/merge_config/clouds.yaml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# This is a clouds.yaml file, which can be used by OpenStack tools as a source
2+
# of configuration on how to connect to a cloud. If this is your only cloud,
3+
# just put this file in ~/.config/openstack/clouds.yaml and tools like
4+
# python-openstackclient will just work with no further config. (You will need
5+
# to add your password to the auth section)
6+
# If you have more than one cloud account, add the cloud entry to the clouds
7+
# section of your existing file and you can refer to them by name with
8+
# OS_CLOUD=openstack or --os-cloud=openstack
9+
clouds:
10+
openstack:
11+
12+
auth:
13+
14+
auth_url: https://auth.os-api.cci1.ecmwf.int:443
15+
16+
application_credential_id: "3bc9c0d0d0644511b549b59b3e861c8f"
17+
application_credential_secret: "hz4TqMG6Z8nXcgGvOEmW2yOvLQxo0-xfRme71KYTt6UzG4asUvPoJLDzDIADj1MDKODJNd9-ILoqvm398rJd9A"
18+
19+
20+
21+
region_name: "RegionOne"
22+
23+
24+
interface: "public"
25+
identity_api_version: 3
26+
auth_type: "v3applicationcredential"

tools/merge_config/inventory/group_vars/all/variables.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@ _magnum_loadbalancer_provider: >-
3838
3939
magnum_loadbalancer_provider: "{{ _magnum_loadbalancer_provider }}"
4040

41-
magnum_helm_chart_version: "0.1.1-dev.0.main.221"
41+
magnum_helm_chart_version: "{{ helm_chart_version.stdout }}"

tools/merge_config/merge_templates.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,37 @@
3030
matching_images: "{{ site_vars | dict2items | selectattr('key', 'match', 'ubuntu*') | list }}"
3131
when: site_vars is defined and site_vars | length > 0
3232

33+
- name: Fetch capi-helm-charts version
34+
shell: "curl -s --url \"https://api.github.com/repos/stackhpc/capi-helm-charts/releases/latest\" --header \"Authorization: Bearer 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\" | grep tag_name | awk -F '\"' '{print $4}' "
35+
register: helm_chart_version
36+
changed_when: false
37+
38+
- name: Fetch dependencies.json using wget
39+
shell: 'wget -O - "https://github.com/stackhpc/capi-helm-charts/releases/download/{{ helm_chart_version.stdout }}/dependencies.json" '
40+
register: dependencies_response
41+
changed_when: false
42+
43+
- name: Parse JSON response
44+
set_fact:
45+
dependencies: "{{ dependencies_response.stdout | from_json | dict2items | list }}"
46+
47+
# - name: Fetch manifest.json using wget
48+
# shell: "wget -O - https://github.com/stackhpc/azimuth-images/releases/download/0.1.2/manifest.json"
49+
# register: manifest_response
50+
# changed_when: false
51+
3352
- name: Fetch manifest.json using wget
34-
shell: "wget -O - 'https://github.com/stackhpc/azimuth-images/releases/download/0.1.2/manifest.json'"
53+
shell: "wget -O - https://github.com/stackhpc/azimuth-images/releases/download/{{ dependencies | json_query('[?key==`azimuth-images`].value | [0]') }}/manifest.json"
3554
register: manifest_response
3655
changed_when: false
3756

3857
- name: Parse JSON response
3958
set_fact:
4059
new_template_data: "{{ manifest_response.stdout | from_json | dict2items | selectattr('key', 'match', 'kubernetes*') | list }}"
4160

61+
- debug:
62+
var: new_template_data
63+
4264
- name: Template images & templates
4365
template:
4466
src: "{{ root_dir }}/examples/templates/capi-images-templates.j2"

0 commit comments

Comments
 (0)