On Fri, 14 Feb 2020 19:00:05 -0800 (PST)
Eric Chang <[email protected]> wrote:

> > - name: load yaml using include_vars with dir
> >   include_vars:
> >     name: 'users'
> >     dir: /home/yaml/users/
> >   delegate_to: localhost 
> >    
> > - name: debug users
> >   debug:
> >     var: 'users'
> >  
> 
> but why debug message shows only the last yaml file content , not the all  
> ??

Works as expected for me. For example the files

  $ cat yaml/users/user1.yml 
  user1: 'user1_var'
  $ cat yaml/users/user2.yml 
  user2: 'user2_var'
  $ cat yaml/users/user3.yml 
  user3: 'user3_var'

give

    "users": {
        "user1": "user1_var", 
        "user2": "user2_var", 
        "user3": "user3_var"
    }

Probably, you might be interested in "DEFAULT_HASH_BEHAVIOUR"
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-hash-behaviour

With the changed variables in the files

  $ cat yaml/users/user1.yml 
  user: 'user1_var'
  $ cat yaml/users/user2.yml 
  user: 'user2_var'
  $ cat yaml/users/user3.yml 
  user: 'user3_var'

the variables overwrite each other, as expected

    "users": {
        "user": "user3_var"
    }


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/20200215043841.4f0783fc%40gmail.com.

Attachment: pgpZZoi9YN0Ru.pgp
Description: OpenPGP digital signature

Reply via email to