Guest User

Untitled

a guest
Apr 16th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. - name: Gather all registered virtual machines
  2. vmware_vm_facts:
  3. validate_certs: no
  4. hostname: IPfromvCenter
  5. username: user
  6. password: PW
  7. register: vmfacts
  8.  
  9. "virtual_machines": {
  10. "Server1": {
  11. "esxi_hostname": "hostname",
  12. "guest_fullname": "Anderes 2.6.x Linux-System (64-Bit)",
  13. "ip_address": "Address",
  14. "mac_address": [
  15. "MAC1",
  16. "MAC2"
  17. ],
  18. "power_state": "poweredOn",
  19. "uuid": "uuid",
  20. "vm_network": {
  21. " MAC1": {
  22. "ipv4": [
  23. "Address"
  24. ],
  25. "ipv6": [
  26. "6Address"
  27. ]
  28. },
  29. " MAC2": {
  30. "ipv4": [],
  31. "ipv6": []
  32. }
  33. }
  34. },
  35. "Server2": {
  36. "esxi_hostname": "hostname",
  37. "guest_fullname": "Anderes 2.6.x Linux-System (64-Bit)",
  38. "ip_address": " Address ",
  39. "mac_address": [
  40. " MAC1",
  41. " MAC2"
  42. ],
  43. "power_state": "poweredOn",
  44. "uuid": " uuid ",
  45. "vm_network": {
  46. " MAC1": {
  47. "ipv4": [
  48. " Address "
  49. ],
  50. "ipv6": [
  51. "6Address "
  52. ]
  53. },
  54. "MAC2": {
  55. "ipv4": [
  56. " Address "
  57. ],
  58. "ipv6": [
  59. "6Address "
  60. ]
  61. }
  62. }
  63. },
  64.  
  65. - name: show name and uuid
  66. debug:
  67. msg: "{{ vmfacts | json_query('virtual_machines') }}"
  68.  
  69. "virtual_machines.[?contains(@, 'Server1')]"
  70.  
  71. "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
  72.  
  73. {{ vmfacts | json_query('keys([?contains(virtual_machines, 'Server1')]') }}
  74.  
  75. "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