Skip to content

Commit a9224b1

Browse files
author
scrungus
committed
capi-image-templates
review changes default to ovn dns unnecessary fields label format change dashes to underscores unnecessary underscores update requirements for new coe template ansible role default dns underscores init version of automated template generation init version of automated template generation init version of automated template generation make operation no-op when no new images are defined and stop new images being included in old image list list concat for images
1 parent 798f72a commit a9224b1

File tree

17 files changed

+435
-3
lines changed

17 files changed

+435
-3
lines changed

etc/openstack-config/openstack-config.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,10 @@
3939
# Configuration of Glance software images.
4040

4141
# List of Glance images. Format is as required by the stackhpc.os-images role.
42-
#openstack_images:
42+
#glance_images:
4343

44+
# Images to be uploaded
45+
#openstack_images: "{{ glance_images + kubernetes_images }}"
4446
# List of Diskimage Builder (DIB) elements paths to include in image builds.
4547
#openstack_image_elements:
4648

@@ -57,4 +59,4 @@
5759

5860
###############################################################################
5961
# Dummy variable to allow Ansible to accept this file.
60-
workaround_ansible_issue_8743: yes
62+
workaround_ansible_issue_8743: yes

examples/capi-templates-images.yml

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
###############################################################################
2+
# Configuration of Glance software images.
3+
4+
# Flavor must have a minimum of 2 VCPUs
5+
magnum_flavor: "m1.small"
6+
7+
# Network to create tenant cluster FIPs on
8+
magnum_external_network: "external"
9+
10+
# Provider for cluster loadbalancers
11+
magnum_octavia_provider: "ovn"
12+
13+
# helm chart version to use for tenant clusters
14+
magnum_helm_chart_version: "openstack-cluster-0.1.1-dev.0.main.221"
15+
16+
ubuntu-focal-kube-v1_25_11:
17+
name: "ubuntu-focal-kube-v1.25.11"
18+
type: qcow2
19+
image_url: "https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_f0dc9cb312144d0aa44037c9149d2513/azimuth-images/ubuntu-focal-kube-v1.25.11-230712-0939.qcow2"
20+
is_public: True
21+
properties:
22+
os_distro: "ubuntu"
23+
os_version: "20.04"
24+
kube_version: "v1.25.11"
25+
26+
ubuntu-focal-kube-v1_26_6:
27+
name: "ubuntu-focal-kube-v1.26.6"
28+
type: qcow2
29+
image_url: "https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_f0dc9cb312144d0aa44037c9149d2513/azimuth-images/ubuntu-focal-kube-v1.26.6-230712-1010.qcow2"
30+
is_public: True
31+
properties:
32+
os_distro: "ubuntu"
33+
os_version: "20.04"
34+
kube_version: "v1.26.6"
35+
36+
ubuntu-focal-kube-v1_27_3:
37+
name: "ubuntu-focal-kube-v1.27.3"
38+
type: qcow2
39+
image_url: "https://object.arcus.openstack.hpc.cam.ac.uk/swift/v1/AUTH_f0dc9cb312144d0aa44037c9149d2513/azimuth-images/ubuntu-focal-kube-v1.27.3-230712-1021.qcow2"
40+
is_public: True
41+
properties:
42+
os_distro: "ubuntu"
43+
os_version: "20.04"
44+
kube_version: "v1.27.3"
45+
46+
# List of Glance images. Format is as required by the stackhpc.os-images role.
47+
openstack_images:
48+
- "{{ ubuntu-focal-kube-v1_25_11 }}"
49+
- "{{ ubuntu-focal-kube-v1_26_6 }}"
50+
- "{{ ubuntu-focal-kube-v1_27_3 }}"
51+
52+
###############################################################################
53+
# Configuration of Magnum container clusters.
54+
55+
kube_v1_25_11:
56+
labels:
57+
monitoring_enabled: "false"
58+
kube_dashboard_enabled: "true"
59+
capi_helm_chart_version: "{{ magnum_helm_chart_version }}"
60+
octavia_provider: "{{ magnum_octavia_provider }}"
61+
external_network_id: "{{ magnum_external_network }}"
62+
master_flavor: "{{ magnum_flavor }}"
63+
flavor: "{{ magnum_flavor }}"
64+
image: "ubuntu-focal-kube-v1.25.11"
65+
name: "kubernetes-v1.25.11"
66+
coe: "kubernetes"
67+
network_driver: "calico"
68+
master_lb_enabled: True
69+
floating_ip_enabled: True
70+
# Magnum’s default value for dns_nameserver is 8.8.8.8.
71+
dns_nameserver: "1.1.1.1,8.8.8.8,8.8.4.4"
72+
public: True
73+
74+
kube_v1_26_6:
75+
labels:
76+
monitoring_enabled: "false"
77+
kube_dashboard_enabled: "true"
78+
capi_helm_chart_version: "{{ magnum_helm_chart_version }}"
79+
octavia_provider: "{{ magnum_octavia_provider }}"
80+
external_network_id: "{{ magnum_external_network }}"
81+
master_flavor: "{{ magnum_flavor }}"
82+
flavor: "{{ magnum_flavor }}"
83+
image: "ubuntu-focal-kube-v1.26.6"
84+
name: "kubernetes-v1.26.6"
85+
coe: "kubernetes"
86+
network_driver: "calico"
87+
master_lb_enabled: True
88+
floating_ip_enabled: True
89+
# Magnum’s default value for dns_nameserver is 8.8.8.8.
90+
dns_nameserver: "1.1.1.1,8.8.8.8,8.8.4.4"
91+
public: True
92+
93+
kube_v1_27_3:
94+
labels:
95+
monitoring_enabled: "false"
96+
kube_dashboard_enabled: "true"
97+
capi_helm_chart_version: "{{ magnum_helm_chart_version }}"
98+
octavia_provider: "{{ magnum_octavia_provider }}"
99+
external_network_id: "{{ magnum_external_network }}"
100+
master_flavor: "{{ magnum_flavor }}"
101+
flavor: "{{ magnum_flavor}}"
102+
image: "ubuntu-focal-kube-v1.27.3"
103+
name: "kubernetes-v1.27.3"
104+
coe: "kubernetes"
105+
network_driver: "calico"
106+
master_lb_enabled: True
107+
floating_ip_enabled: True
108+
# Magnum’s default value for dns_nameserver is 8.8.8.8.
109+
dns_nameserver: "1.1.1.1,8.8.8.8,8.8.4.4"
110+
public: True
111+
112+
# List of magnum cluster templates. Format is as required by the
113+
# stackhpc.os-container-clusters role.
114+
openstack_container_clusters_templates:
115+
- "{{ kube_v1_25_11 }}"
116+
- "{{ kube_v1_26_6 }}"
117+
- "{{ kube_v1_27_3 }}"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
###############################################################################
2+
# Magnum container clusters shared variables.
3+
4+
# Flavor must have a minimum of 2 VCPUs
5+
magnum_flavor: {{ magnum_flavor_name }}
6+
7+
# Network to create tenant cluster FIPs on
8+
magnum_external_network: {{ magnum_external_net_name }}
9+
10+
# Provider for cluster loadbalancers
11+
magnum_octavia_provider: {{ magnum_loadbalancer_provider }}
12+
13+
# helm chart version to use for tenant clusters
14+
magnum_helm_chart_version: {{ magnum_helm_chart_version }}
15+
16+
{% include './old-images.j2' %}
17+
{% include './images.j2' %}
18+
19+
{% include './old-templates.j2' %}
20+
{% include './templates.j2' %}

examples/templates/images.j2

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
###############################################################################
2+
# Configuration of Glance software images.
3+
4+
{% for item in new_template_data %}
5+
# Image for {{ item.key }}
6+
{{ item.value.name }}:
7+
name: "{{ item.value.name }}"
8+
type: qcow2
9+
image_url: "{{ item.value.url }}"
10+
is_public: True
11+
properties:
12+
os_distro: "ubuntu"
13+
os_version: "20.04"
14+
kube_version: "{{ item.value.kubernetes_version }}"
15+
16+
{% endfor %}
17+
# List of Kubernetes images. Format is as required by the stackhpc.os-images role.
18+
kubernetes_images:
19+
{% if matching_images is defined and matching_temps | length > 0 %}
20+
{% for item in matching_images %}
21+
{% if item.value.name not in new_template_data | map(attribute='value.name') %}
22+
- "{{ '{{ ' + item.key + ' }}' }}"
23+
{% endif %}
24+
{% endfor %}
25+
{% endif %}
26+
{% for item in new_template_data %}
27+
- "{{ '{{ ' + item.value.name + ' }}' }}"
28+
{% endfor %}

examples/templates/old-images.j2

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{% if matching_images is defined and matching_temps | length > 0 %}
2+
###############################################################################
3+
# Old magnum images - hide until out of use
4+
5+
{% for item in matching_images %}
6+
{% if item.value.name not in new_template_data | map(attribute='value.name') %}
7+
{{ item.key }}:
8+
{% for key, value in item.value.items() %}
9+
{% if value is mapping %}
10+
{{ key }}:
11+
{% for k, v in value.items() %}
12+
{{ k }}: "{{ v }}"
13+
{% endfor %}
14+
{% else %}
15+
{{ key }}: "{{ value }}"
16+
{% endif %}
17+
{% endfor %}
18+
19+
{% endif %}
20+
{% endfor %}
21+
{% endif %}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
{% if matching_temps is defined and matching_temps | length > 0 %}
2+
###############################################################################
3+
# Old magnum templates - hide until out of use
4+
5+
{% for item in matching_temps %}
6+
{% if item.key not in new_template_data | map(attribute='key') %}
7+
{{ item.key }}:
8+
{% for key, value in item.value.items() %}
9+
{% if key == 'is_hidden' %}
10+
{{ key }}: {{ value }}
11+
{% elif value is mapping %}
12+
{{ key }}:
13+
{% for k, v in value.items() %}
14+
{{ k }}: "{{ v }}"
15+
{% endfor %}
16+
{% else %}
17+
{{ key }}: "{{ value }}"
18+
{% endif %}
19+
{% endfor %}
20+
{% if 'is_hidden' not in item.value %}
21+
is_hidden: True
22+
{% endif %}
23+
24+
{% endif %}
25+
{% endfor %}
26+
{% endif %}

examples/templates/templates.j2

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
###############################################################################
2+
# Configuration of Magnum container clusters.
3+
4+
{% for item in new_template_data %}
5+
{{ item.key }}:
6+
labels:
7+
monitoring_enabled: "true"
8+
kube_dashboard_enabled: "true"
9+
capi_helm_chart_version: "{{ magnum_helm_chart_version }}"
10+
octavia_provider: {{ magnum_loadbalancer_provider }}
11+
external_network_id: {{ magnum_external_net_name }}
12+
master_flavor: {{ magnum_flavor_name }}
13+
flavor: {{ magnum_flavor_name }}
14+
image: "{{ item.value.name }}"
15+
name: "{{ item.key }}"
16+
coe: "kubernetes"
17+
network_driver: "calico"
18+
master_lb_enabled: True
19+
floating_ip_enabled: True
20+
dns_nameserver: "1.1.1.1,8.8.8.8,8.8.4.4"
21+
public: True
22+
23+
{% endfor %}
24+
# List of magnum cluster templates. Format is as required by the
25+
# stackhpc.os-container-clusters role.
26+
openstack_container_clusters_templates:
27+
{% if matching_temps is defined and matching_temps | length > 0 %}
28+
{% for item in matching_temps %}
29+
{% if item.key not in new_template_data | map(attribute='key') %}
30+
- "{{ '{{ ' + item.key + ' }}' }}"
31+
{% endif %}
32+
{% endfor %}
33+
{% endif %}
34+
{% for item in new_template_data %}
35+
- "{{ '{{ ' + item.key + ' }}' }}"
36+
{% endfor %}

requirements.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ roles:
99

1010
collections:
1111
- name: openstack.cloud
12-
version: '<2'
12+
version: 2.1.0

tools/merge_config/ansible.cfg

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[defaults]
2+
inventory = ./inventory

tools/merge_config/bin/activate

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#####
2+
# This script activates the specified environment
3+
#
4+
# It needs to be sourced rather than just executed as it sets environment variables
5+
# for the current shell
6+
#####
7+
export CONFIG_ROOT="$(dirname $(dirname $(dirname $(dirname $(realpath ${BASH_SOURCE[0]:-${(%):-%x}})))))"
8+
9+
# If clouds.yaml provided in root dir, then prefer this
10+
if [ -f "$CONFIG_ROOT/tools/merge_config/clouds.yaml" ]; then
11+
export OS_CLOUD="${OS_CLOUD:-"openstack"}"
12+
export OS_CLIENT_CONFIG_FILE="$CONFIG_ROOT/tools/merge_config/clouds.yaml"
13+
fi
14+
15+
# If a Python virtualenv exists, activate it
16+
VENV="${VENV:-"$CONFIG_ROOT/tools/merge_config/.venv"}"
17+
if [ -f "$VENV/bin/activate" ]; then
18+
echo "Activating Python venv at $VENV"
19+
source "$VENV/bin/activate"
20+
fi
21+
22+
echo "Activated environment"

0 commit comments

Comments
 (0)