Unable to recall/display multiple register value in single ansible play book.

16 views
Skip to first unread message

jaya...@gmail.com

unread,
May 17, 2021, 5:06:48 AM5/17/21
to Ansible Project
Hi Team,

I want to register multiple values and to display the details at the end. I have created a small playbook with two register value as mentioned below, but its display only single value instead of two. Can some body guide me how to achieve this task.
=======================
playbook
---
- name: Gather esxi info
  hosts: all
  tasks:
     - name: vmware version
       command: esxcli system version get
       register: ESXi_Version
     - name: Virtual Machines
       command: vim-cmd vmsvc/getallvms
       register: Provisioned_VirtualMachines
     - debug:
         var={{Provisioned_VirtualMachines.stdout_lines,ESXi_Version.stdout_lines}}

============================================

output

TASK [Virtual Machines] ************************************************************************************************************************************************************************************
changed: [xxxxxxxxx]

TASK [debug] ***********************************************************************************************************************************************************************************************
ok: [xxxxxxxxxx] => {
    "Provisioned_VirtualMachines.stdout_lines": [
        "Vmid           Name                                        File                                     Guest OS          Version             Annotation           ",
        "1      Win2012                 [datastore1] Win2012/Win2012.vmx                               windows8Server64Guest   vmx-14                                   ",
        "12     VMware vCenter Server   [datastore1] VMware vCenter Server/VMware vCenter Server.vmx   other3xLinux64Guest     vmx-10    VMware vCenter Server Appliance",
        "2      RHEL7.7                 [datastore1] RHEL7.7/RHEL7.7.vmx                               rhel7_64Guest           vmx-14                                   ",
        "5      Win2019                 [datastore1] Win2019/Win2019.vmx                               windows9Server64Guest   vmx-14                                   "
    ]
}

PLAY RECAP *************************************************************************************************************************************************************************************************
xxxxxxxxxxx          : ok=3    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0

Regards,
Jayan

Stefan Hornburg (Racke)

unread,
May 17, 2021, 5:33:27 AM5/17/21
to ansible...@googlegroups.com
On 5/17/21 11:06 AM, jaya...@gmail.com wrote:
> Hi Team,
>
> I want to register multiple values and to display the details at the end. I have created a small playbook with two
> register value as mentioned below, but its display only single value instead of two. Can some body guide me how to
> achieve this task.
> =======================
> playbook
> ---
> - name: Gather esxi info
>   hosts: all
>   tasks:
>      - name: vmware version
>        command: esxcli system version get
>        register: ESXi_Version
>      - name: Virtual Machines
>        command: vim-cmd vmsvc/getallvms
>        register: Provisioned_VirtualMachines
>      - debug:
>          var={{Provisioned_VirtualMachines.stdout_lines,ESXi_Version.stdout_lines}}

debug: var: This is used for variable names.

Please try

debug:
msg: "{{Provisioned_VirtualMachines.stdout_lines }},{{ ESXi_Version.stdout_lines}}"

Regards
Racke
> --
> 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
> ansible-proje...@googlegroups.com <mailto:ansible-proje...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/cda4fa38-d38c-483f-9468-b2a2920ea251n%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/cda4fa38-d38c-483f-9468-b2a2920ea251n%40googlegroups.com?utm_medium=email&utm_source=footer>.


--
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

OpenPGP_signature

Jayan Anirudhan

unread,
May 17, 2021, 7:00:37 AM5/17/21
to ansible...@googlegroups.com
Hi Racke,

Thanks a lot for the guidance from your side. Finally it started working.

Regards,
Jayan

To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/c24e7a40-1aa3-2e2e-ddfd-e8bf26f3854b%40linuxia.de.


--
Regards,

Jayan Anirudhan
Mob:09885994156
Reply all
Reply to author
Forward
0 new messages