That did the trick!
Here's my configuration now, for completeness:
vars:
splunkforwarder_log_items:
- app1_name: var_log
source: "/var/log"
recursive: true
index: "testindex"
splunkforwarder_log_files:
- logfile: "messages"
app_name: "var_log"
sourcetype: linux_messages_syslog
task:
- name: drop props configuration
template:
src=props_conf.j2
dest={{splunkforwarder_dir}}/etc/apps/{{ item.app_name }}/props.conf
owner=splunk
group=splunk
mode=640
with_items: splunkforwarder_log_files
template:
{% for source in splunkforwarder_log_files %}
[source::.../{{source.logfile}}]
sourcetype = {{source.sourcetype}}
{% endfor %}
Thanks!
Am Dienstag, 12. August 2014 16:14:18 UTC+2 schrieb Michael DeHaan:
>
> 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]
> <javascript:>> 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] <javascript:>.
>> To post to this group, send email to [email protected]
>> <javascript:>.
>> 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/07547963-998e-4988-97a7-b8404e4df28c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.