From 9199809da56cbabcfc6cf00ced6264d6232fcd6c Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Sun, 6 Nov 2022 14:21:35 +0100 Subject: [PATCH] Fix variable names;Add clusterctl config template --- .../roles/metacluster/tasks/components.yml | 22 +++++++++++++--- .../roles/metacluster/templates/clusterctl.j2 | 26 +++++++++++++++++++ ansible/vars/metacluster.yml | 4 +-- 3 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 ansible/roles/metacluster/templates/clusterctl.j2 diff --git a/ansible/roles/metacluster/tasks/components.yml b/ansible/roles/metacluster/tasks/components.yml index 11fe5af..81c1c58 100644 --- a/ansible/roles/metacluster/tasks/components.yml +++ b/ansible/roles/metacluster/tasks/components.yml @@ -4,10 +4,10 @@ state: directory loop: - /opt/metacluster/helm-charts - - /opt/metacluster/manifests/bootstrap-kubeadm/{{ components.cluster-api.manifest.version.base }} - - /opt/metacluster/manifests/cluster-api/{{ components.cluster-api.manifest.version.base }} - - /opt/metacluster/manifests/control-plane-kubeadm/{{ components.cluster-api.manifest.version.base }} - - /opt/metacluster/manifests/infrastructure-vsphere/{{ components.cluster-api.manifest.version.infrastructure-vsphere }} + - /opt/metacluster/manifests/bootstrap-kubeadm/{{ components.clusterapi.manifest.version.base }} + - /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/container-images - name: Add helm repositories @@ -86,6 +86,20 @@ # ansible.builtin.set_fact: # clusterapi_containerimages: "{{ parsedmanifests | json_query('results[*].stdout') }}" + # - name: Configure clusterctl + # ansible.builtin.template: + # src: clusterctl.j2 + # dest: /opt/metacluster/manifests/clusterctl.yaml + # vars: + # _template: + # hv: + # username: + # password: + # fqdn: + # version: + # base: + # infrastructure_vsphere: + - name: Parse helm charts for container images ansible.builtin.shell: cmd: "{{ item.value.helm.parse_logic }}" diff --git a/ansible/roles/metacluster/templates/clusterctl.j2 b/ansible/roles/metacluster/templates/clusterctl.j2 new file mode 100644 index 0000000..d07ad2f --- /dev/null +++ b/ansible/roles/metacluster/templates/clusterctl.j2 @@ -0,0 +1,26 @@ +providers: + - name: "kubeadm" + url: "/opt/metacluster/manifests/bootstrap-kubeadm/{{ _template.version.base }}/bootstrap-components.yaml" + type: "BootstrapProvider" + - name: "cluster-api" + url: "/opt/metacluster/manifests/cluster-api/{{ _template.version.base }}/core-components.yaml" + type: "CoreProvider" + - name: "kubeadm" + url: "/opt/metacluster/manifests/control-plane-kubeadm/{{ _template.version.base }}/control-plane-components.yaml" + type: "ControlPlaneProvider" + - name: "vsphere" + url: "/opt/metacluster/manifests/infrastructure-vsphere/{{ _template.version.infrastructure-vsphere }}/infrastructure-components.yaml" + type: "InfrastructureProvider" + +## -- Controller settings -- ## +VSPHERE_USERNAME: "{{ _template.hv.username }}" +VSPHERE_PASSWORD: "{{ _template.hv.password }}" +## -- Required workload cluster default settings -- ## +VSPHERE_SERVER: "{{ _template.hv.fqdn }}" +VSPHERE_DATACENTER: "{{ _template.hv.datacenter }}" +VSPHERE_DATASTORE: "{{ _template.hv.datastore }}" +VSPHERE_NETWORK: "{{ _template.hv.network }}" +#VSPHERE_RESOURCE_POOL: "" +#VSPHERE_FOLDER: "" +#VSPHERE_TEMPLATE: "centos-7-kube-v1.18.2" +#VSPHERE_SSH_AUTHORIZED_KEY: "output of cat /root/.ssh/id_rsa.pub" diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index 26e2676..74623b9 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -76,11 +76,11 @@ components: # chart_values: !unsafe | # installCRDs: true - cluster-api: + clusterapi: manifest: version: base: v1.2.4 - infrastructure-vsphere: v1.3.5 + infrastructure_vsphere: v1.3.5 gitea: helm: