From 83ee632ff9f9596ae753fd8146165828711e57f4 Mon Sep 17 00:00:00 2001 From: Danny Bessems Date: Thu, 17 Nov 2022 09:22:58 +0100 Subject: [PATCH] Move task;Fix static value;Improve shell logic/ansible filter;Fix typo --- .../roles/workloadcluster/tasks/clusterapi.yml | 7 +------ .../roles/workloadcluster/tasks/hypervisor.yml | 9 +++++++-- ansible/roles/metacluster/tasks/components.yml | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) 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 732c901..6e7fffc 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 @@ -1,8 +1,3 @@ -- name: Retrieve hypervisor TLS thumbprint - ansible.builtin.shell: - cmd: openssl s_client -connect {{ vapp['hv.fqdn'] }}:443 < /dev/null 2>/dev/null | openssl x509 -fingerprint -noout -in /dev/stdin - register: tls_thumbprint - - name: Configure clusterctl ansible.builtin.template: src: clusterctl.j2 @@ -15,7 +10,7 @@ infrastructure_vsphere: "{{ components.clusterapi.management.version.infrastructure_vsphere }}" hv: fqdn: "{{ vapp['hv.fqdn'] }}" - tlsthumbprint: "{{ (tls_thumbprint.stdout | split('='))[-1] }}" + tlsthumbprint: "{{ vcenter_info.tls_thumbprint }}" username: "{{ vapp['hv.username'] }}" password: "{{ vapp['hv.password'] }}" datacenter: "{{ vcenter_info.datacenter }}" diff --git a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/hypervisor.yml b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/hypervisor.yml index 69a1d7d..964a022 100644 --- a/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/hypervisor.yml +++ b/ansible/roles/firstboot/files/ansible_payload/roles/workloadcluster/tasks/hypervisor.yml @@ -38,15 +38,20 @@ part: NF - attribute: resourcepool moref: >- - $(govc object.collect -json /DeSchakel/vm/Kubernetes.Bootstrap.Appliance2 | + $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ jq -r '.[] | select(.Name == "resourcePool").Val | .Type + ":" + .Value') part: 0 loop_control: label: "{{ item.attribute }}" +- name: Retrieve hypervisor TLS thumbprint + ansible.builtin.shell: + cmd: openssl s_client -connect {{ vapp['hv.fqdn'] }}:443 < /dev/null 2>/dev/null | openssl x509 -fingerprint -noout -in /dev/stdin | awk -F'=' '{print $2}' + register: tls_thumbprint + - name: Store hypervisor details in dictionary ansible.builtin.set_fact: - vcenter_info: "{{ vcenter_info | default({}) | combine({ item.item.attribute : item.stdout }) }}" + vcenter_info: "{{ vcenter_info | default({}) | combine({ item.item.attribute : item.stdout }) | combine({ 'tls_thumbprint': tls_thumbprint.stdout }) }}" loop: "{{ govc_inventory.results }}" loop_control: label: "{{ item.item.attribute }}" diff --git a/ansible/roles/metacluster/tasks/components.yml b/ansible/roles/metacluster/tasks/components.yml index f23e832..5cd9b79 100644 --- a/ansible/roles/metacluster/tasks/components.yml +++ b/ansible/roles/metacluster/tasks/components.yml @@ -112,7 +112,7 @@ docker://{{ item }} \ docker-archive:./{{ ( item | regex_findall('[^/:]+'))[-2] }}_{{ uid }}.tar:{{ item }} chdir: /opt/metacluster/container-images - var: + vars: uid: "{{ lookup('ansible.builtin.password', '/dev/null length=5 chars=ascii_lowercase,digits seed=item') }}" loop: "{{ ((containerimages.results | map(attribute='stdout_lines') | select('defined') | flatten) + dependencies.container_images + (clusterapi_containerimages | list)) | unique }}"