From 8926b72344f1049fbdb7984f436ad6955f9aff8b Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Tue, 8 Nov 2022 08:54:33 +0100 Subject: [PATCH] Rebase node templates;Switch to linked clones;Rename dictionary;Add debugging --- .../workloadcluster/tasks/nodetemplates.yml | 11 ++++ .../roles/metacluster/tasks/components.yml | 56 ++++++++++--------- ansible/vars/metacluster.yml | 5 +- ansible/vars/workloadcluster.yml | 7 ++- 4 files changed, 49 insertions(+), 30 deletions(-) diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/nodetemplates.yml b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/nodetemplates.yml index 2c8d069..f4f46f9 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/nodetemplates.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/nodetemplates.yml @@ -37,6 +37,17 @@ loop_control: index_var: index + - name: Create snapshot on deployed VM's + community.vmware.vmware_guest_snapshot: + folder: "{{ vcenter_info.folder }}" + name: "{{ (item | basename | split('.'))[:-1] | join('.') }}" + state: present + snapshot_name: "{{ ansible_date_time..iso8601_basic_short }}-base" + loop: "{{ ova_deploy.results }}" + loop_control: + index_var: index + label: "{{ item.item }}" + - name: Mark deployed VM's as templates community.vmware.vmware_guest: name: "{{ item.instance.hw_name }}" diff --git a/ansible/roles/metacluster/tasks/components.yml b/ansible/roles/metacluster/tasks/components.yml index c364ab3..981178a 100644 --- a/ansible/roles/metacluster/tasks/components.yml +++ b/ansible/roles/metacluster/tasks/components.yml @@ -4,11 +4,11 @@ state: directory loop: - /opt/metacluster/helm-charts - - /opt/metacluster/manifests/bootstrap-kubeadm/{{ components.clusterapi.manifest.version.base }} - - /opt/metacluster/manifests/cert-manager/{{ components.clusterapi.manifest.version.cert_manager }} - - /opt/metacluster/manifests/cluster-api/{{ components.clusterapi.manifest.version.base }} - - /opt/metacluster/manifests/control-plane-kubeadm/{{ components.clusterapi.manifest.version.base }} - - /opt/metacluster/manifests/infrastructure-vsphere/{{ components.clusterapi.manifest.version.infrastructure_vsphere }} + - /opt/metacluster/manifests/bootstrap-kubeadm/{{ components.clusterapi.management.version.base }} + - /opt/metacluster/manifests/cert-manager/{{ components.clusterapi.management.version.cert_manager }} + - /opt/metacluster/manifests/cluster-api/{{ components.clusterapi.management.version.base }} + - /opt/metacluster/manifests/control-plane-kubeadm/{{ components.clusterapi.management.version.base }} + - /opt/metacluster/manifests/infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }} - /opt/metacluster/container-images - name: Add helm repositories @@ -37,6 +37,10 @@ loop_control: label: "{{ item.key }}" + - debug: + msg: | + {{ { 'components': (chart_values + { 'clusterapi': components.clusterapi } ) } | to_nice_yaml(indent=2, width=4096) }} + - name: Write dict to vars_file ansible.builtin.copy: dest: /opt/firstboot/ansible/vars/metacluster.yml @@ -52,26 +56,26 @@ 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.manifest.version.base }}/bootstrap-components.yaml - dest: bootstrap-kubeadm/{{ components.clusterapi.manifest.version.base }}/bootstrap-components.yaml - - url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.manifest.version.base }}/core-components.yaml - dest: cluster-api/{{ components.clusterapi.manifest.version.base }}/core-components.yaml - - url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.manifest.version.base }}/control-plane-components.yaml - dest: control-plane-kubeadm/{{ components.clusterapi.manifest.version.base }}/control-plane-components.yaml - - url: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/download/{{ components.clusterapi.manifest.version.infrastructure_vsphere }}/infrastructure-components.yaml - dest: infrastructure-vsphere/{{ components.clusterapi.manifest.version.infrastructure_vsphere }}/infrastructure-components.yaml - - url: https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/releases/download/{{ components.clusterapi.manifest.version.infrastructure_vsphere }}/metadata.yaml - dest: infrastructure-vsphere/{{ components.clusterapi.manifest.version.infrastructure_vsphere }}/metadata.yaml + - 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 + - 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 }}/metadata.yaml + dest: infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}/metadata.yaml # This downloads the same metadata.yaml file to three separate folders - - url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.manifest.version.base }}/metadata.yaml - dest: bootstrap-kubeadm/{{ components.clusterapi.manifest.version.base }}/metadata.yaml - - url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.manifest.version.base }}/metadata.yaml - dest: cluster-api/{{ components.clusterapi.manifest.version.base }}/metadata.yaml - - url: https://github.com/kubernetes-sigs/cluster-api/releases/download/{{ components.clusterapi.manifest.version.base }}/metadata.yaml - dest: control-plane-kubeadm/{{ components.clusterapi.manifest.version.base }}/metadata.yaml + - 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 # Additionally, cert-manager is a prerequisite - - url: https://github.com/cert-manager/cert-manager/releases/download/{{ components.clusterapi.manifest.version.cert_manager }}/cert-manager.yaml - dest: cert-manager/{{ components.clusterapi.manifest.version.cert_manager }}/cert-manager.yaml + - 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 loop_control: label: "{{ item.url | basename }}" @@ -94,9 +98,9 @@ vars: _template: version: - base: "{{ components.clusterapi.manifest.version.base }}" - cert_manager: "{{ components.clusterapi.manifest.version.cert_manager }}" - infrastructure_vsphere: "{{ components.clusterapi.manifest.version.infrastructure_vsphere }}" + base: "{{ components.clusterapi.management.version.base }}" + cert_manager: "{{ components.clusterapi.management.version.cert_manager }}" + infrastructure_vsphere: "{{ components.clusterapi.management.version.infrastructure_vsphere }}" - name: Parse helm charts for container images ansible.builtin.shell: diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index 4011fca..52db274 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -77,13 +77,16 @@ components: # installCRDs: true clusterapi: - manifest: + management: version: # Must match the version referenced at `dependencies.static_binaries[.filename==clusterctl].url` base: v1.2.4 # Must match the version referenced at `components.cert-manager.helm.version` cert_manager: v1.9.1 infrastructure_vsphere: v1.3.5 + workload: + version: + k8s: v1.23.5 gitea: helm: diff --git a/ansible/vars/workloadcluster.yml b/ansible/vars/workloadcluster.yml index 0f75ff2..e28b66b 100644 --- a/ansible/vars/workloadcluster.yml +++ b/ansible/vars/workloadcluster.yml @@ -1,7 +1,8 @@ downstream: node_templates: - prefix: NodeTmpl_ + prefix: ClusterAPITemplate_ images: - - url: https://stable.release.flatcar-linux.net/amd64-usr/3227.2.0/flatcar_production_vmware_ova.ova - name: flatcar.ova + # Refer to `https://github.com/kubernetes-sigs/cluster-api-provider-vsphere/blob/v1.3.5/README.md#kubernetes-versions-with-published-ovas` for a list of supported node templates + - url: https://storage.googleapis.com/capv-images/release/v1.23.5/ubuntu-2004-kube-v1.23.5.ova + name: ubuntu-2004-kube-v1.23.5.ova