Hi,
I would like to read vm hostname from a VM Folder and use it to estract the list of windows disks.
I tried with the following code, but it doesn’t work.
I obtain:
TASK [debug] **********************************************************************************************************************************************************************
ok: [localhost] => {
"hostnames": [
"hostabc"
]
}
TASK [List disks with drive letters] **********************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "module_stderr": "/bin/sh: 1: powershell: not found\n", "module_stdout": "", "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error", "rc": 127}
This is my playbook:
- name: vm read on folder VMWARE
hosts: localhost
become: false
gather_facts: true
vars_files:
- secrets.yml
- vars.yml
collections:
- community.vmware
- community.windows
tasks:
- name: Gather VM info
community.vmware.vmware_vm_info:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
folder: "/{{ vcenter_datacenter }}/vm/Ansible"
register: vm_info
- set_fact:
hostnames: "{{ vm_info.virtual_machines | json_query(query) | map(attribute='guest_name') | list }}"
vars:
query: "[?guest_name!=null]"
- debug: var=hostnames
- name: List disks with drive letters
community.windows.win_disk_facts:
delegate_to: "{{ hostnames }}"
filter:
- partitions
How could I correctly give the vms to the win_disk_facts?
Thanks a lot.
Mario