Skip to content

Commit

Permalink
trying this with mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
acozine committed Sep 4, 2024
1 parent 132c8c1 commit f4d79a7
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions playbooks/utils/vSphere_audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,21 @@
ansible.builtin.debug:
var: esxi_memory_for_all_vms

- name: View ESXi memory used by VMs
- name: Try ESXI memory stats with mapping
ansible.builtin.debug:
msg: The VMs on the {{ item.item }} host are using {{ item.ansible_facts.vm_memory_array | int * 1048576 | human_readable }}
msg: The VMs on {{ item.0 }} are using {{ item.1 | int * 104576 | human_readable }}
with_together:
- "{{ esxi_memory_for_all_vms | map(attribute='ESXI_host') | list }}"
- "{{ esxi_memory_for_all_vms | map(attribute='Sum_of_vm_mmory_in_MB') | list }}"

# This attempt gave us a long array of 1 KB messages . . .
# - name: View ESXi memory used by VMs
# ansible.builtin.debug:
# msg: The VMs on the {{ item.item }} host are using {{ item.ansible_facts.vm_memory_array | int * 1048576 | human_readable }}
# this part gives 0 GB
# because the var in the loop does not match the Name attribute in slim_esxi_host_memory
# out of {{ slim_esxi_host_memory | selectattr('Name', 'equalto', item) | map(attribute='Totalmemory') | sum | human_readable(unit='G') }} total.
loop: "{{ vm_memory_per_esxi_host.results }}"
# loop: "{{ vm_memory_per_esxi_host.results }}"

- name: show number of VMs by esxi_hostname
ansible.builtin.debug:
Expand Down

0 comments on commit f4d79a7

Please sign in to comment.