Hi, i use this playbook:

---
- hosts: host1
  gather_facts: false
  connection: local

  tasks:

    - name: Gather disk facts from virtual machine using name
      vmware_guest_disk_facts:
        # Unirse a vsphere
        hostname: "{{ hostname }}"
        username: "{{ username }}"
        password: "{{ password }}"
        datacenter: Datacenter
        # Para pasar por el SSH sin autenticar nada
        validate_certs: no
        # Nombre de la maquina
        name: "{{vm}}"
      delegate_to: localhost
      # Lo metemos en una variable
      register: disk_facts

    - debug:
        msg: "{{disk_facts.guest_disk_facts}}"
...

and the result is:

ok: [host1] => {
    "msg": {
        "0": {
            "backing_datastore": "datastore1",
            "backing_disk_mode": "persistent",
            "backing_eagerlyscrub": false,
            "backing_filename": "[datastore1] 
ANSIBLE_Centos/ANSIBLE_Centos-000003.vmdk",
            "backing_thinprovisioned": false,
            "backing_writethrough": false,
            "capacity_in_bytes": 17179869184,
            "capacity_in_kb": 16777216,
            "controller_key": 1000,
            "key": 2000,
            "label": "Hard disk 1",
            "summary": "16,777,216 KB",
            "unit_number": 0
        },
        "1": {
            "backing_datastore": "datastore1",
            "backing_disk_mode": "persistent",
            "backing_eagerlyscrub": false,
            "backing_filename": "[datastore1] 
ANSIBLE_Centos/ANSIBLE_Centos_3.vmdk",
            "backing_thinprovisioned": false,
            "backing_writethrough": false,
            "capacity_in_bytes": 2147483648,
            "capacity_in_kb": 2097152,
            "controller_key": 1000,
            "key": 2001,
            "label": "Hard disk 2",
            "summary": "2,097,152 KB",
            "unit_number": 1
        }
    }
}

Good, i need second ("1") hard disk info, but when im use  variable 
disk_facts.guest_disk_facts.1 the result is:

fatal: [host1]: FAILED! => {"msg": "The task includes an option with an 
undefined variable. The error was: dict object has no element 1\n\nThe 
error appears to have been in '/root/playbook/operations/ListVMvalues.yml': 
line 50, column 7, but may\nbe elsewhere in the file depending on the exact 
syntax problem.\n\nThe offending line appears to be:\n\n\n    - debug:\n    
  ^ here\n"}

What I do?

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/56c12ea3-45ea-4382-8bea-b5bd4dd86662%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to