With what you have above, item.0 is the overall list and item.1 is each
item in the splunkforwarder_log_files, however it looks like you shouldn't
be using "with_subelements" at all, because the only variable in your task
definition that changes is item.0

Unless I'm missing something, I would switch to a basic "with_items" and
avoid calling the template task multiple times, and then just rely on the
loop inside the template.



On Tue, Aug 12, 2014 at 8:10 AM, Sebastian Gumprich <[email protected]>
wrote:

> Hi,
>
> I have the following variables:
>
> splunkforwarder_log_items:
>   - source: "/var/log"
>     app_name: "var_log"
>     recursive: true
>     index: "testindex"
>     splunkforwarder_log_files:
>       - logfile: "messages"
>         name: "var_log"
>         sourcetype: linux_messages_syslog
>
>
>
> and the following task:
>
> - name: drop props configuration
>   template:
>     src=props_conf.j2
>     dest={{splunkforwarder_dir}}/etc/apps/{{item.0.app_name}}/props.conf
>     owner=splunk
>     group=splunk
>     mode=640
>   with_subelements:
>     - splunkforwarder_log_items
>     - splunkforwarder_log_files
>
>
>
> Is it possible to use the variables from the subelement "
> splunkforwarder_log_files" in the "props_conf.j2"-template? For example
> like this:
>
> {% for sources in splunkforwarder_log_items.splunkforwarder_log_files %}
> [source::.../{{sources.logfile}}]
> sourcetype = {{sources.sourcetype}}
> {% endfor %}
>
>
>
> Or is there a simpler alternative?
>
> Regards
> Sebastian
>
> --
> 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/6fa6b0f5-5bac-455c-bb8b-9cbd05ae5c76%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/6fa6b0f5-5bac-455c-bb8b-9cbd05ae5c76%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BnsWgz84szzonwvV0S377xXcajuAypFKReWi1nCaRXn4wkSYg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to