On Fri, 14 Feb 2020 19:00:05 -0800 (PST)
Eric Chang <
chan...@gmail.com> 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