diff --git a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/hypervisor.yml b/ansible/roles/firstboot/files/ansible_payload/common/roles/workloadcluster/tasks/hypervisor.yml similarity index 76% rename from ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/hypervisor.yml rename to ansible/roles/firstboot/files/ansible_payload/common/roles/workloadcluster/tasks/hypervisor.yml index a83da4c..6ac0525 100644 --- a/ansible/roles/firstboot/files/ansible_payload/bootstrap/roles/workloadcluster/tasks/hypervisor.yml +++ b/ansible/roles/firstboot/files/ansible_payload/common/roles/workloadcluster/tasks/hypervisor.yml @@ -11,7 +11,7 @@ - attribute: cluster moref: >- $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - jq -r '.[] | select(.Name == "runtime").Val.Host | .Type + ":" + .Value') + jq -r '.[] | select(.name == "runtime").val.host | .type + ":" + .value') part: (NF-1) - attribute: datacenter moref: VirtualMachine:{{ moref_id }} @@ -19,27 +19,27 @@ - attribute: datastore moref: >- $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - jq -r '.[] | select(.Name == "datastore").Val.ManagedObjectReference | .[].Type + ":" + .[].Value') + jq -r '.[] | select(.name == "datastore").val._value | .[].type + ":" + .[].value') part: NF - attribute: folder moref: >- $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - jq -r '.[] | select(.Name == "parent").Val | .Type + ":" + .Value') + jq -r '.[] | select(.name == "parent").val | .type + ":" + .value') part: 0 # - attribute: host # moref: >- # $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - # jq -r '.[] | select(.Name == "runtime").Val.Host | .Type + ":" + .Value') + # jq -r '.[] | select(.name == "runtime").val.host | .type + ":" + .value') # part: NF - attribute: network moref: >- $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - jq -r '.[] | select(.Name == "network").Val.ManagedObjectReference | .[].Type + ":" + .[].Value') + jq -r '.[] | select(.name == "network").val._value | .[].type + ":" + .[].value') part: NF - attribute: resourcepool moref: >- $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - jq -r '.[] | select(.Name == "resourcePool").Val | .Type + ":" + .Value') + jq -r '.[] | select(.name == "resourcePool").val | .type + ":" + .value') part: 0 loop_control: label: "{{ item.attribute }}" diff --git a/ansible/roles/firstboot/files/ansible_payload/upgrade/roles/workloadcluster/tasks/hypervisor.yml b/ansible/roles/firstboot/files/ansible_payload/upgrade/roles/workloadcluster/tasks/hypervisor.yml deleted file mode 100644 index a83da4c..0000000 --- a/ansible/roles/firstboot/files/ansible_payload/upgrade/roles/workloadcluster/tasks/hypervisor.yml +++ /dev/null @@ -1,57 +0,0 @@ -- name: Gather hypervisor details - ansible.builtin.shell: - cmd: govc ls -L {{ item.moref }} | awk -F/ '{print ${{ item.part }}}' - environment: - GOVC_INSECURE: '1' - GOVC_URL: "{{ vapp['hv.fqdn'] }}" - GOVC_USERNAME: "{{ vapp['hv.username'] }}" - GOVC_PASSWORD: "{{ vapp['hv.password'] }}" - register: govc_inventory - loop: - - attribute: cluster - moref: >- - $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - jq -r '.[] | select(.Name == "runtime").Val.Host | .Type + ":" + .Value') - part: (NF-1) - - attribute: datacenter - moref: VirtualMachine:{{ moref_id }} - part: 2 - - attribute: datastore - moref: >- - $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - jq -r '.[] | select(.Name == "datastore").Val.ManagedObjectReference | .[].Type + ":" + .[].Value') - part: NF - - attribute: folder - moref: >- - $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - jq -r '.[] | select(.Name == "parent").Val | .Type + ":" + .Value') - part: 0 - # - attribute: host - # moref: >- - # $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - # jq -r '.[] | select(.Name == "runtime").Val.Host | .Type + ":" + .Value') - # part: NF - - attribute: network - moref: >- - $(govc object.collect -json VirtualMachine:{{ moref_id }} | \ - jq -r '.[] | select(.Name == "network").Val.ManagedObjectReference | .[].Type + ":" + .[].Value') - part: NF - - attribute: resourcepool - moref: >- - $(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 }) }}" - loop: "{{ govc_inventory.results }}" - loop_control: - label: "{{ item.item.attribute }}"