Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - name: Gather all registered virtual machines
- vmware_vm_facts:
- validate_certs: no
- hostname: IPfromvCenter
- username: user
- password: PW
- register: vmfacts
- "virtual_machines": {
- "Server1": {
- "esxi_hostname": "hostname",
- "guest_fullname": "Anderes 2.6.x Linux-System (64-Bit)",
- "ip_address": "Address",
- "mac_address": [
- "MAC1",
- "MAC2"
- ],
- "power_state": "poweredOn",
- "uuid": "uuid",
- "vm_network": {
- " MAC1": {
- "ipv4": [
- "Address"
- ],
- "ipv6": [
- "6Address"
- ]
- },
- " MAC2": {
- "ipv4": [],
- "ipv6": []
- }
- }
- },
- "Server2": {
- "esxi_hostname": "hostname",
- "guest_fullname": "Anderes 2.6.x Linux-System (64-Bit)",
- "ip_address": " Address ",
- "mac_address": [
- " MAC1",
- " MAC2"
- ],
- "power_state": "poweredOn",
- "uuid": " uuid ",
- "vm_network": {
- " MAC1": {
- "ipv4": [
- " Address "
- ],
- "ipv6": [
- "6Address "
- ]
- },
- "MAC2": {
- "ipv4": [
- " Address "
- ],
- "ipv6": [
- "6Address "
- ]
- }
- }
- },
- - name: show name and uuid
- debug:
- msg: "{{ vmfacts | json_query('virtual_machines') }}"
- "virtual_machines.[?contains(@, 'Server1')]"
- "msg": "JMESPathError in json_query filter plugin:nExpecting: ['quoted_identifier', 'unquoted_identifier', 'lbracket', 'lbrace'], got: filter: Parse error at column 17, token "[?" (FILTER), for expression:n"virtual_machines.[?contains(@, 'Server1')]"n
- {{ vmfacts | json_query('keys([?contains(virtual_machines, 'Server1')]') }}
- "msg": "template error while templating string: expected token ',', got 'KURMI'. String: {{ vmfacts | json_query('keys([?contains(virtual_machines, 'Server1')]') }}"
Add Comment
Please, Sign In to add comment