# Using vars\_files

**URL:** <https://forum.ansible.com/t/using-vars-files/32406>\
**Category:** Ansible Project\
**Created:** [March 6, 2020, 2:05pm UTC](https://forum.ansible.com/t/using-vars-files/32406 "2020-03-06T14:05:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brandon\_Daly](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Brandon\_Daly](https://forum.ansible.com/u/Brandon_Daly)\
**Post date:** [March 6, 2020, 2:05pm UTC](https://forum.ansible.com/t/using-vars-files/32406/1 "2020-03-06T14:05:16Z")

</div>

I have a play that is creating yaml for each of my hosts and this is stored in './host\_vars/{{ inventory\_hostname }}/l3vpn.yml

I then have a second play in which I wish to use this yaml.

both are called from another playbook;

[ansible@ansi001 juniper]$ more live.all.pb.yam

---

<div class="post-metadata">

**Author:** ![racke](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/racke/32/4767_2.png) [@racke](https://forum.ansible.com/u/racke)\
**Post date:** [March 6, 2020, 2:20pm UTC](https://forum.ansible.com/t/using-vars-files/32406/2 "2020-03-06T14:20:44Z")

</div>

> I have a play that is creating yaml for each of my hosts and this is stored in './host\_vars/{{ inventory\_hostname  
> }}/l3vpn.yml
> 
> I then have a second play in which I wish to use this yaml.
> 
> both are called from another playbook;
> 
> [ansible@ansi001 juniper]$ more live.all.pb.yam  
> ---  
> - import\_playbook: make\_clean.p.yaml  
> - import\_playbook: l3vpnconf.p.yaml \< this one creates the per host yaml  
> - import\_playbook: createconfig.p.yaml \< this one attempt to use them  
> - import\_playbook: assemble\_and\_commit.p.yaml
> 
> In createconfigp.p.yaml I've attempted to access the l3vpn yaml using;
> 
> vars\_files:  
> - ./host\_vars/{{ inventory\_hostname }}/engendered\_l3vpn.yml
> 
> but this produces the error 'ERROR! vars file ./host\_vars/{{ inventory\_hostname }}/l3vpn.yml was not found'
> 
> Is it possible to create yaml per host in one play and have the second play use the yaml?

I suppose you need to wrap it in "" to evaluate it as Jinja template:

- "./host\_vars/{{ inventory\_hostname }}/engendered\_l3vpn.yml"

Regards  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Racke

---

<div class="post-metadata">

**Author:** ![Brandon\_Daly](https://avatars.discourse-cdn.com/v4/letter/b/8c91f0/32.png) [@Brandon\_Daly](https://forum.ansible.com/u/Brandon_Daly)\
**Post date:** [March 6, 2020, 2:31pm UTC](https://forum.ansible.com/t/using-vars-files/32406/3 "2020-03-06T14:31:32Z")

</div>

I have this working.

I’ve a role that configs the L3VPN, so I created two tasks within that role. One loads the vars, and the other produces the router configuration.

roles/config\_l3vpn/tasks/load.yml
