chore: Refactor jq keys according to govc output
This commit is contained in:
parent
2db1c4d623
commit
dda14af238
@ -11,7 +11,7 @@
|
|||||||
- attribute: cluster
|
- attribute: cluster
|
||||||
moref: >-
|
moref: >-
|
||||||
$(govc object.collect -json VirtualMachine:{{ moref_id }} | \
|
$(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)
|
part: (NF-1)
|
||||||
- attribute: datacenter
|
- attribute: datacenter
|
||||||
moref: VirtualMachine:{{ moref_id }}
|
moref: VirtualMachine:{{ moref_id }}
|
||||||
@ -19,27 +19,27 @@
|
|||||||
- attribute: datastore
|
- attribute: datastore
|
||||||
moref: >-
|
moref: >-
|
||||||
$(govc object.collect -json VirtualMachine:{{ moref_id }} | \
|
$(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
|
part: NF
|
||||||
- attribute: folder
|
- attribute: folder
|
||||||
moref: >-
|
moref: >-
|
||||||
$(govc object.collect -json VirtualMachine:{{ moref_id }} | \
|
$(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
|
part: 0
|
||||||
# - attribute: host
|
# - attribute: host
|
||||||
# moref: >-
|
# moref: >-
|
||||||
# $(govc object.collect -json VirtualMachine:{{ moref_id }} | \
|
# $(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
|
# part: NF
|
||||||
- attribute: network
|
- attribute: network
|
||||||
moref: >-
|
moref: >-
|
||||||
$(govc object.collect -json VirtualMachine:{{ moref_id }} | \
|
$(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
|
part: NF
|
||||||
- attribute: resourcepool
|
- attribute: resourcepool
|
||||||
moref: >-
|
moref: >-
|
||||||
$(govc object.collect -json VirtualMachine:{{ moref_id }} | \
|
$(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
|
part: 0
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.attribute }}"
|
label: "{{ item.attribute }}"
|
@ -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 }}"
|
|
Loading…
Reference in New Issue
Block a user