# Complex Variables from a File from GroupVars?

**URL:** <https://forum.ansible.com/t/complex-variables-from-a-file-from-groupvars/13807>\
**Category:** Ansible Project\
**Created:** [October 30, 2013, 9:23pm UTC](https://forum.ansible.com/t/complex-variables-from-a-file-from-groupvars/13807 "2013-10-30T21:23:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe2](https://avatars.discourse-cdn.com/v4/letter/j/3e96dc/32.png) [@Joe2](https://forum.ansible.com/u/Joe2)\
**Post date:** [October 30, 2013, 9:23pm UTC](https://forum.ansible.com/t/complex-variables-from-a-file-from-groupvars/13807/1 "2013-10-30T21:23:59Z")

</div>

I’m new to ansible. I have used the group\_vars/dbservers file to reference a single simple variable but now trying to link a file containing complex variables list.  
Put most simply what is the syntax for adding a file or file reference (similar to vars\_files) to group\_vars for a given role?  
I’m guessing I need a file group\_vars/common.yml but vars\_files doesn’t seem to work here.

I get the vars\_files inside the playbook to work successfully as below but was unsuccessful concerning the group\_vars solution for a role.

Following the example from ‘[coderwall.com - Use ‘with\_items’ with complex arguments to simplify handler logic](https://coderwall.com/p/uaeeug)’

> - name: template everything for fuser

> template: src=${item.src} dest=${item.dest} with\_items: ${fooserv\_template\_files} notify: - restart fooserv

> Of course we could also define the list you were walking over in another file, like a “group_vars/webservers" file to define all the variables needed for the webservers group, or a YAML file loaded from the "vars_files” directive inside the playbook. Look how this can clean up if we do.

My issue is that if I run the my common playbook standalone the file is included via vars\_files but if I run the web playbook which only executes the common role tasks the file contents are unavailable throwing “One or more undefined variables: ‘str object’ has no attribute ‘name’” . I’ve followed the directory layout of [Ansible Best Practices](http://www.ansibleworks.com/docs/playbooks_best_practices.html).
