Hi,
your file looks like JSON to me, not like YAML (though one is a subset of the other, if I remember correctly…).
My test:
### teams.yaml ###
---
chinese_name: "\u8ca1\u52d9\u6703\u8a08\u8655"
description: "\u8ca1\u52d9\u6703\u8a08\u8655"
gid": 10126
location":
- "hq"
name: "ac"
users:
- tsengyi
- chenp
- lich
- hsiaoch
- wangr
- dengm
- guot
##################
### test.yaml ###
---
- hosts: localhost
gather_facts: false
tasks:
- include_vars: teams.yaml
- debug:
msg: '{{ item }}'
loop: '{{ users }}'
#################
results in:
$ ansible-playbook test.yaml
PLAY [localhost] ***************************************************************
TASK [include_vars] ************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => (item=tsengyi) =>
msg: tsengyi
ok: [localhost] => (item=chenp) =>
msg: chenp
ok: [localhost] => (item=lich) =>
msg: lich
ok: [localhost] => (item=hsiaoch) =>
msg: hsiaoch
ok: [localhost] => (item=wangr) =>
msg: wangr
ok: [localhost] => (item=dengm) =>
msg: dengm
ok: [localhost] => (item=guot) =>
msg: guot
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
I you want the content of teams.yaml to be inside variable "teams" you need to tell that Ansible:
tasks:
- include_vars:
file: teams.yaml
name: teams
That way, you can refer to teams["users"] and not just to users as in my test.yaml.
Am 22.11.18 um 14:08 schrieb Eric Chang:
> --
> 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 post to this group, send email to
ansible...@googlegroups.com <mailto:
ansible...@googlegroups.com>.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/ansible-project/4e7e34a9-48b8-4d6a-bd82-d04361dfeaca%40googlegroups.com
> <
https://groups.google.com/d/msgid/ansible-project/4e7e34a9-48b8-4d6a-bd82-d04361dfeaca%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit
https://groups.google.com/d/optout.