On 24. aug. 2016 23:25, Douglas Hammond wrote:
I'm trying to create client configs for each host in a group.  When the
template is parsed the inventory set variable is not available in the
template.

bareos/Defaults/main.yml

bareos_client_fileset: SomeFileSet

This is not a inventory file syntax, maybe you are looking for group_vars and/or host_vars.

The directory structure Ansible understand is documented here
https://docs.ansible.com/ansible/playbooks_best_practices.html#directory-layout


bareos/tasks/main.yml

- name: Install director client configs
  template:
    src: client.conf.j2
    dest: /etc/bareos/bareos-dir.d/clients/{{ item }}.conf
  with_items: "{{ groups['bareos_clients'] }}"


bareos/templates/client.conf.js

{{ hostvars[item]['bareos_client_fileset'] }}


How can I get the correct inventory variable from hostvars in this case?

I recommend starting read here
https://docs.ansible.com/ansible/intro.html
it will give you a basic understanding of Ansible.

--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/aef15612-97e8-02e2-1a71-6e773e29e021%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to