From 6bd49750a4b6759b69ad37bed60f9cd9b275fb74 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Wed, 15 Mar 2023 10:24:45 +0100 Subject: [PATCH] Add missing key/parameter;Fix dependency type;Add k8s version to filename --- .drone.yml | 3 +++ .../bootstrap/roles/workloadcluster/tasks/clusterapi.yml | 5 ++++- .../files/ansible_payload/bootstrap/templates/ippool.j2 | 1 + .../bootstrap/templates/kustomization.cluster-template.j2 | 2 ++ ansible/vars/metacluster.yml | 1 + packer/build.pkr.hcl | 2 +- packer/variables.pkr.hcl | 2 ++ 7 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index c9961ae..e69dbc2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -25,6 +25,8 @@ steps: - | sed -i -e "s/<>/$${SSH_PASSWORD}/g" \ packer/preseed/UbuntuServer22.04/user-data + - | + export K8S_VERSION=$(yq '.components.clusterapi.workload.version.k8s' < ./ansible/vars/metacluster.yml) - | yamllint -d "{extends: relaxed, rules: {line-length: disable}}" \ ansible \ @@ -45,6 +47,7 @@ steps: -var repo_password=$${REPO_PASSWORD} \ -var ssh_password=$${SSH_PASSWORD} \ -var vsphere_password=$${VSPHERE_PASSWORD} \ + -var k8s_version=$K8S_VERSION ./packer - | packer build \ diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml index df5aed6..74e703d 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/clusterapi.yml @@ -75,7 +75,9 @@ dest: /opt/metacluster/cluster-api/infrastructure-vsphere/{{ components.clusterapi.management.version.infrastructure_vsphere }}/kustomization.yaml vars: _template: - fqdn: "{{ vapp['metacluster.fqdn'] }}" + network: + fqdn: "{{ vapp['metacluster.fqdn'] }}" + dnsserver: "{{ vapp['guestinfo.dnsserver'] }}" rootca: "{{ stepca_cm_certs.resources[0].data['root_ca.crt'] }}" # script: # # Base64 encoded; to avoid variable substitution when clusterctl parses the cluster-template.yml @@ -168,6 +170,7 @@ _template: cluster: name: "{{ vapp['workloadcluster.name'] | lower }}" + namespace: default network: startip: "{{ vapp['ippool.startip'] }}" endip: "{{ vapp['ippool.endip'] }}" diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/ippool.j2 b/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/ippool.j2 index d737141..fe77036 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/ippool.j2 +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/ippool.j2 @@ -2,6 +2,7 @@ apiVersion: ipam.cluster.x-k8s.io/v1alpha1 kind: InClusterIPPool metadata: name: inclusterippool-{{ _template.cluster.name }} + namespace: {{ _template.cluster.namespace }} spec: start: {{ _template.cluster.network.startip }} end: {{ _template.cluster.network.endip }} diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.cluster-template.j2 b/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.cluster-template.j2 index e2258e6..5288956 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.cluster-template.j2 +++ b/ansible/roles/firstboot/files/ansible_payload/bootstrap/templates/kustomization.cluster-template.j2 @@ -76,6 +76,8 @@ patchesStrategicMerge: - apiGroup: ipam.cluster.x-k8s.io kind: InClusterIPPool name: inclusterippool-${CLUSTER_NAME} + nameservers: + - {{ _template.network.dnsserver }} networkName: '${VSPHERE_NETWORK}' patchesJson6902: diff --git a/ansible/vars/metacluster.yml b/ansible/vars/metacluster.yml index 97ee877..54ba3ae 100644 --- a/ansible/vars/metacluster.yml +++ b/ansible/vars/metacluster.yml @@ -296,6 +296,7 @@ dependencies: extra_opts: --strip-components=1 - filename: kubectl-slice url: https://github.com/patrickdappollonio/kubectl-slice/releases/download/v1.2.5/kubectl-slice_linux_x86_64.tar.gz + archive: compressed # - filename: npp-prepper # url: https://code.spamasaurus.com/api/packages/djpbessems/generic/npp-prepper/v0.5.1/npp-prepper - filename: skopeo diff --git a/packer/build.pkr.hcl b/packer/build.pkr.hcl index 349f083..fa6e9d9 100644 --- a/packer/build.pkr.hcl +++ b/packer/build.pkr.hcl @@ -53,7 +53,7 @@ build { " -ManifestFileName '/scratch/airgapped-k8s/${source.name}/ova.${source.name}-${var.vm_name}.mf'", "ovftool --acceptAllEulas --allowExtraConfig --overwrite \\", " '/scratch/airgapped-k8s/${source.name}/ova.${source.name}-${var.vm_name}.ovf' \\", - " /output/airgapped-k8s.${source.name}.ova" + " /output/airgapped-k8s-${var.k8s_version}.${source.name}.ova" ] } } diff --git a/packer/variables.pkr.hcl b/packer/variables.pkr.hcl index 5321395..9c4cba0 100644 --- a/packer/variables.pkr.hcl +++ b/packer/variables.pkr.hcl @@ -33,3 +33,5 @@ variable "docker_username" {} variable "docker_password" { sensitive = true } + +variable "k8s_version" {}