2022-11-28 15:58:56 +00:00
|
|
|
- block:
|
|
|
|
|
2023-08-22 10:54:07 +00:00
|
|
|
- name: Aggregate meta-cluster chart_values into dict
|
2022-11-28 15:58:56 +00:00
|
|
|
ansible.builtin.set_fact:
|
2023-04-05 08:47:17 +00:00
|
|
|
metacluster_chartvalues: "{{ metacluster_chartvalues | default({}) | combine({ item.key: { 'chart_values': (item.value.helm.chart_values | from_yaml) } }) }}"
|
2022-11-28 15:58:56 +00:00
|
|
|
when: item.value.helm.chart_values is defined
|
2023-04-05 11:37:31 +00:00
|
|
|
loop: "{{ query('ansible.builtin.dict', components) }}"
|
2022-11-28 15:58:56 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.key }}"
|
|
|
|
|
2023-08-22 10:54:07 +00:00
|
|
|
- name: Combine and write dict to vars_file
|
2022-11-28 15:58:56 +00:00
|
|
|
ansible.builtin.copy:
|
|
|
|
dest: /opt/firstboot/ansible/vars/metacluster.yml
|
2023-01-21 15:12:11 +00:00
|
|
|
content: >-
|
|
|
|
{{
|
|
|
|
{ 'components': (
|
2023-03-28 20:31:11 +00:00
|
|
|
metacluster_chartvalues |
|
2023-10-22 18:49:35 +00:00
|
|
|
combine({ 'clusterapi': components['clusterapi'] }) |
|
|
|
|
combine({ 'kubevip' : components['kubevip'] }) |
|
|
|
|
combine({ 'pinniped' : components['pinniped'] })),
|
2023-07-07 14:48:32 +00:00
|
|
|
'appliance': {
|
|
|
|
'version': (applianceversion)
|
|
|
|
}
|
2023-01-21 15:12:11 +00:00
|
|
|
} | to_nice_yaml(indent=2, width=4096)
|
|
|
|
}}
|
2022-11-28 15:58:56 +00:00
|
|
|
|
2023-08-22 10:54:07 +00:00
|
|
|
- name: Aggregate workload-cluster chart_values into dict
|
2023-04-04 20:44:56 +00:00
|
|
|
ansible.builtin.set_fact:
|
2023-08-22 10:54:07 +00:00
|
|
|
workloadcluster_chartvalues: |
|
|
|
|
{{
|
|
|
|
workloadcluster_chartvalues | default({}) | combine({
|
|
|
|
item.key: {
|
|
|
|
'chart_values': (item.value.chart_values | default('') | from_yaml),
|
|
|
|
'extra_manifests': (item.value.extra_manifests | default([])),
|
|
|
|
'namespace': (item.value.namespace)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}}
|
2023-04-05 11:37:31 +00:00
|
|
|
loop: "{{ query('ansible.builtin.dict', downstream.helm_charts) }}"
|
2023-04-04 20:44:56 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.key }}"
|
|
|
|
|
|
|
|
- name: Write dict to vars_file
|
|
|
|
ansible.builtin.copy:
|
|
|
|
dest: /opt/firstboot/ansible/vars/workloadcluster.yml
|
|
|
|
content: >-
|
|
|
|
{{
|
|
|
|
{ 'downstream_components': ( workloadcluster_chartvalues )
|
|
|
|
} | to_nice_yaml(indent=2, width=4096)
|
|
|
|
}}
|
|
|
|
|
2023-08-21 07:02:33 +00:00
|
|
|
- name: Download Cluster-API manifests
|
2022-11-28 15:58:56 +00:00
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: "{{ item.url }}"
|
|
|
|
dest: /opt/metacluster/cluster-api/{{ item.dest }}
|
|
|
|
register: clusterapi_manifests
|
|
|
|
loop:
|
|
|
|
# This list is based on `clusterctl config repositories`
|
|
|
|
# Note: Each manifest also needs a `metadata.yaml` file stored in the respective folder
|
|
|
|
- url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.management.version.base }}/bootstrap-components.yaml
|
|
|
|
dest: bootstrap-kubeadm/{{ components.clusterapi.management.version.base }}/bootstrap-components.yaml
|
|
|
|
- url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.management.version.base }}/core-components.yaml
|
|
|
|
dest: cluster-api/{{ components.clusterapi.management.version.base }}/core-components.yaml
|
|
|
|
- url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.management.version.base }}/control-plane-components.yaml
|
|
|
|
dest: control-plane-kubeadm/{{ components.clusterapi.management.version.base }}/control-plane-components.yaml
|
|
|
|
# This downloads the same `metadata.yaml` file to three separate folders
|
|
|
|
- url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.management.version.base }}/metadata.yaml
|
|
|
|
dest: bootstrap-kubeadm/{{ components.clusterapi.management.version.base }}/metadata.yaml
|
|
|
|
- url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.management.version.base }}/metadata.yaml
|
|
|
|
dest: cluster-api/{{ components.clusterapi.management.version.base }}/metadata.yaml
|
|
|
|
- url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.management.version.base }}/metadata.yaml
|
|
|
|
dest: control-plane-kubeadm/{{ components.clusterapi.management.version.base }}/metadata.yaml
|
|
|
|
# The vsphere infrastructure provider requires multiple files (`cluster-template.yaml` and `metadata.yaml` on top of default files)
|
|
|
|
- url: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/download/{{ components.clusterapi.management.version.infrastructure_vsphere }}/infrastructure-components.yaml
|
|
|
|
dest: infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}/infrastructure-components.yaml
|
|
|
|
- url: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/download/{{ components.clusterapi.management.version.infrastructure_vsphere }}/cluster-template.yaml
|
|
|
|
dest: infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}/cluster-template.yaml
|
|
|
|
- url: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/download/{{ components.clusterapi.management.version.infrastructure_vsphere }}/metadata.yaml
|
|
|
|
dest: infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}/metadata.yaml
|
|
|
|
# Additionally, cert-manager is a prerequisite
|
|
|
|
- url: https://github.com/cert-manager/cert-manager/releases/download/{{ components.clusterapi.management.version.cert_manager }}/cert-manager.yaml
|
|
|
|
dest: cert-manager/{{ components.clusterapi.management.version.cert_manager }}/cert-manager.yaml
|
|
|
|
# Finally, workload clusters will need a CNI plugin
|
|
|
|
- url: https://raw.githubusercontent.com/projectcalico/calico/{{ components.clusterapi.workload.version.calico }}/manifests/calico.yaml
|
|
|
|
dest: cni-calico/{{ components.clusterapi.workload.version.calico }}/calico.yaml
|
2022-12-04 10:22:17 +00:00
|
|
|
# IPAM in-cluster provider (w/ metadata.yaml)
|
|
|
|
- url: https://github.com/telekom/cluster-api-ipam-provider-in-cluster/releases/download/{{ components.clusterapi.management.version.ipam_incluster }}/ipam-components.yaml
|
2022-12-10 15:56:13 +00:00
|
|
|
dest: ipam-in-cluster/{{ components.clusterapi.management.version.ipam_incluster }}/ipam-components.yaml
|
2022-12-04 10:22:17 +00:00
|
|
|
- url: https://github.com/telekom/cluster-api-ipam-provider-in-cluster/releases/download/{{ components.clusterapi.management.version.ipam_incluster }}/metadata.yaml
|
2022-12-10 15:56:13 +00:00
|
|
|
dest: ipam-in-cluster/{{ components.clusterapi.management.version.ipam_incluster }}/metadata.yaml
|
2022-11-28 15:58:56 +00:00
|
|
|
loop_control:
|
|
|
|
label: "{{ item.url | basename }}"
|
2023-01-05 16:21:40 +00:00
|
|
|
retries: 5
|
|
|
|
delay: 5
|
2022-11-28 15:58:56 +00:00
|
|
|
until: clusterapi_manifests is not failed
|
|
|
|
|
2023-03-29 20:01:43 +00:00
|
|
|
- name: Update cluster-template with image tags
|
|
|
|
ansible.builtin.replace:
|
2023-03-29 20:53:56 +00:00
|
|
|
dest: /opt/metacluster/cluster-api/infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}/cluster-template.yaml
|
2023-03-29 20:01:43 +00:00
|
|
|
regexp: ':\${CPI_IMAGE_K8S_VERSION}'
|
|
|
|
replace: ":{{ components.clusterapi.management.version.cpi_vsphere }}"
|
|
|
|
|
2023-01-21 15:12:11 +00:00
|
|
|
- name: Download kube-vip RBAC manifest
|
|
|
|
ansible.builtin.get_url:
|
|
|
|
url: https://kube-vip.io/manifests/rbac.yaml
|
|
|
|
dest: /opt/metacluster/kube-vip/rbac.yaml
|
2023-01-21 15:58:51 +00:00
|
|
|
register: kubevip_manifest
|
2023-01-21 15:12:11 +00:00
|
|
|
retries: 5
|
|
|
|
delay: 5
|
|
|
|
until: kubevip_manifest is not failed
|
|
|
|
|
2023-10-22 13:20:34 +00:00
|
|
|
- name: Download pinniped local-user-authenticator manifest
|
|
|
|
ansible.builtin.get_url:
|
2023-10-22 18:49:35 +00:00
|
|
|
url: https://get.pinniped.dev/{{ components.pinniped['local-user-authenticator'].version }}/install-local-user-authenticator.yaml
|
2023-10-22 13:20:34 +00:00
|
|
|
dest: /opt/metacluster/pinniped/local-user-authenticator.yaml
|
|
|
|
register: pinniped_manifest
|
|
|
|
retries: 5
|
|
|
|
delay: 5
|
|
|
|
until: pinniped_manifest is not failed
|
|
|
|
|
|
|
|
- name: Trim image hash from manifest
|
2023-10-24 07:28:24 +00:00
|
|
|
ansible.builtin.replace:
|
|
|
|
path: /opt/metacluster/pinniped/local-user-authenticator.yaml
|
|
|
|
regex: '([ ]*image: .*)@.*'
|
|
|
|
replace: '\\1'
|
2023-10-22 13:20:34 +00:00
|
|
|
no_log: true
|
|
|
|
|
2022-11-28 15:58:56 +00:00
|
|
|
# - name: Inject manifests
|
|
|
|
# ansible.builtin.template:
|
|
|
|
# src: "{{ item.type }}.j2"
|
|
|
|
# dest: /var/lib/rancher/k3s/server/manifests/{{ item.name }}-manifest.yaml
|
|
|
|
# owner: root
|
|
|
|
# group: root
|
|
|
|
# mode: 0600
|
2023-04-05 11:37:31 +00:00
|
|
|
# loop: "{{ query('ansible.builtin.dict', components) | map(attribute='value.manifests') | list | select('defined') | flatten }}"
|
2022-11-28 15:58:56 +00:00
|
|
|
# loop_control:
|
2023-01-25 09:28:28 +00:00
|
|
|
# label: "{{ item.type ~ '/' ~ item.name }}"
|