On Sun, 1 Mar 2020 21:37:42 -0800 (PST)
Shifa Shaikh <[email protected]> wrote:

> listings.yml
> 
> ---
> 10.9.9.42:
>   - name: myapp
>     path: /app/myapp_war.ear/myapp.war
>   - name: myapp JS
>     path: /app/myapp_war.ear/myapp.war/javascripts
> 10.9.9.43:
>   - name: CVS
>     path: /app/CVS.ear/CVS.war/ui/js
>   - name: CHK
>     path: /app/logs/tmp
>   - name: SSO
>     path: /app/CVS.ear/CVS.war/WEB-INF
>
> [...]
>
>   tasks:
>    - name: Load entire repository inventory
>      include_vars:
>        file="{{ playbook_dir }}/vars/listing.yml"
>     name: user1
> 
>    - debug:
>        msg: "Name {{ item.0.name }} on path{{ item.0.path }}"
>      loop:
>        - "{{ inventory_hostname }}"

The variables from the file are assigned into the dictionary "user1". Fix the
variables' references

    - debug:
        msg: "Name {{ user1[item].0.name }} on path {{ user1[item].0.path }}"
      loop:
        - "{{ inventory_hostname }}"

With single item the loop is not necessary

    - debug:
        msg: "Name {{ user1[inventory_hostname].0.name }} on
              path {{ user1[inventory_hostname].0.path }}"

HTH,
        -vlado

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/20200302071017.4a7fae12%40gmail.com.

Attachment: pgpD2GstzGpBR.pgp
Description: OpenPGP digital signature

Reply via email to