From b47dda7a500cb225114f091488cfae6800996136 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Wed, 9 Nov 2022 16:43:49 +0100 Subject: [PATCH] Enable gather facts; Fix typo and conditional;Add missing manifests;Initialize cluster API --- .../firstboot/files/ansible_payload/playbook.yml | 2 +- .../roles/workloadcluster/tasks/clusterapi.yml | 5 +++++ .../roles/workloadcluster/tasks/nodetemplates.yml | 3 ++- ansible/roles/metacluster/tasks/components.yml | 15 +++++++++------ 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ansible/roles/firstboot/files/ansible_payload/playbook.yml b/ansible/roles/firstboot/files/ansible_payload/playbook.yml index e1abad3..1ab6933 100644 --- a/ansible/roles/firstboot/files/ansible_payload/playbook.yml +++ b/ansible/roles/firstboot/files/ansible_payload/playbook.yml @@ -1,7 +1,7 @@ --- - hosts: 127.0.0.1 connection: local - gather_facts: false + gather_facts: true vars_files: - metacluster.yml # become: true diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml index 2f0ca32..3c228fc 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/clusterapi.yml @@ -27,3 +27,8 @@ publickey: "{{ vapp['guestinfo.rootsshkey'] }}" version: "{{ components.clusterapi.workload.version.k8s }}" vip: "{{ vapp['workloadcluster.vip'] }}" + +- name: Initialize Cluster API management cluster + ansible.builtin.shell: + cmd: clusterctl init -v5 -i vsphere:{{ components.clusterapi.management.version.infrastructure_vsphere }} --config ./clusterctl.yaml + chdir: /opt/metacluster/manifests 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 1c3b188..ef35a09 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 @@ -42,7 +42,8 @@ folder: "{{ vcenter_info.folder }}" name: "{{ item.instance.hw_name }}" state: present - snapshot_name: "{{ ansible_date_time..iso8601_basic_short }}-base" + snapshot_name: "{{ ansible_date_time.iso8601_basic_short }}-base" + when: ova_deploy.results[index] is not skipped loop: "{{ ova_deploy.results }}" loop_control: index_var: index diff --git a/ansible/roles/metacluster/tasks/components.yml b/ansible/roles/metacluster/tasks/components.yml index 1c5ca75..b0198a3 100644 --- a/ansible/roles/metacluster/tasks/components.yml +++ b/ansible/roles/metacluster/tasks/components.yml @@ -51,24 +51,27 @@ 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 + # 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 - - 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 + # 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