Using vars_files

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

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
         Racke

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