Playbook -- How to read a value from another yaml file ?

I have this playbook which changes the xml file on a remote server.
This playbook needs to read a value from another yaml file.

For example source yaml file:
main.yml
cluster: onecluster

product: someproduct

playbook.yml
-replace: dest=/a/b/cd.xml regexp=something replace=<<< value of cluster from main.yml >>>

The playbook.yml changes the value as per the value from main.yml.
I cannot not hardcode that in the playbook.yml, all the values should come from central place(main.yml)

Thank you in advance.

I'm not 100% sure if I understand the question, but your inventory can
associate extra yaml files with all hosts or with groups of hosts. The
documentation is fairly reasonable:
http://docs.ansible.com/intro_inventory.html (group_vars are what you
want, and are discussed at the end)

As an aside, the Ansible convention for global defaults is the "all" group.

Thanks, I solved the problem by using extra-vars.

vars_files:

  • /path/to/foo.yaml

Would be the most idiomatic way to read a YAML file in a playbook.

That makes sense , I can populate the yaml before executing the playbook.
Thanks for the suggestion.