-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathgenerate-magnum-capi-templates.yml
More file actions
60 lines (51 loc) · 2.2 KB
/
generate-magnum-capi-templates.yml
File metadata and controls
60 lines (51 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
- name: Generate cluster templates
hosts: localhost
vars:
root_dir: ../
tasks:
- name: Check that required variables are defined
assert:
that:
- magnum_default_master_flavor_name is defined
- magnum_default_worker_flavor_name is defined
- magnum_external_net_name is defined
- magnum_loadbalancer_provider is defined
- name: Fetch capi-helm-charts release information
ansible.builtin.uri:
url: https://api.github.com/repos/stackhpc/capi-helm-charts/releases/latest
register: capi_helm_chart_release_data
- name: Fetch dependencies.json for capi-helm-charts release
ansible.builtin.uri:
url: https://raw.githubusercontent.com/stackhpc/capi-helm-charts/{{ capi_helm_chart_release_data.json.tag_name }}/dependencies.json
register: dependencies_response
- name: Ensure wget packages is installed
become: true
package:
name: wget
state: present
- name: Fetch manifest.json for capi-helm-charts images
# ansible.builtin.uri:
# url: https://raw.githubusercontent.com/stackhpc/azimuth-images/{{ dependencies_response.json['azimuth-images'] }}/manifest.json
# Above URL returns 404 even though similar URL for capi-helm-charts repo works fine
# Not sure why but fall back to wget + JSON parsing for now.
shell: "wget -O - https://github.com/stackhpc/azimuth-images/releases/download/{{ dependencies_response.json['azimuth-images'] }}/manifest.json"
register: manifest_response
changed_when: false
- name: Parse JSON response
set_fact:
new_template_data: "{{ manifest_response.stdout | from_json | dict2items | selectattr('key', 'match', 'kubernetes*') | list }}"
- name: Ensure output dir exists
ansible.builtin.file:
path: "{{ [root_dir, 'generated-magnum-snippets', now(utc=true,fmt='%Y-%m-%d-T%H-%M-%S')] | path_join }}"
state: directory
mode: '0755'
register: output_dir
- name: Write new image config to file
template:
src: "magnum-capi-images.j2"
dest: "{{ output_dir.path }}/images.yml"
- name: Write new cluster template config to file
template:
src: "magnum-capi-templates.j2"
dest: "{{ output_dir.path }}/templates.yml"