On Sat, 15 Feb 2020 00:16:02 -0800 (PST) Eric Chang <[email protected]> wrote:
> so any suggesions to combine multiple yaml files with same attributes ?
Sure. For example
- set_fact:
users: "{{ users|
default({})|
combine({my_key: my_value}) }}"
vars:
my_key: "{{ (item|basename|splitext).0 }}"
my_value: "{{ lookup('file', item)|from_yaml }}"
with_fileglob: "yaml/users2/*.yml"
- debug:
var: users
give
"users": {
"user1": {
"user": "user1_var"
},
"user2": {
"user": "user2_var"
},
"user3": {
"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/20200215104239.50f217e2%40gmail.com.
pgpjz5I8OB6DJ.pgp
Description: OpenPGP digital signature
