Hi,
New to Ansible and probably not using it the way most are. I’m a network engineer and am trying to use it to generate config files using the template module. It’s working well for one file but I’d like to extend it to support multiple “hosts” that use different variables.
In my hosts file, I only have localhost defined (since I’m just writing data to files). I have a role “switch” that includes one task using with_items set to “hostname: item1” etc. I am wondering if you can specify a vars_files for each of the “items”? I tried to set vars_files in the playbook site.yml to “vars/roles/switch/vars/{{item.hostname}}.yml” but that doesn’t work. I think I could “trick” Ansible by defining multiple hosts to resolve to 127.0.0.1 in the hosts file but would rather avoid that. Any suggestions?