Re: [ansible-project] Same list from multiple vars-files consolidated

2015-01-08 Thread Sebastian Gumprich
Thanks for your input.
I tried setting hash_behaviour to "merge" but this doesn't work. Even when 
I put the two lists into one vars-file, only the last list will be used.
But you mentioning naming the variable different gave me an idea. I'm using 
different variables in group_vars and host_vars now and use multiple tasks 
and templates.

Thanks!


Am Mittwoch, 7. Januar 2015 15:11:30 UTC+1 schrieb Brian Coca:
>
> ansible by default will override previous definitions with newer ones, 
> in this case group 'all' gets loaded first and then overwritten by 
> group1. 
>
> You can change this behavior globally using the hash_behaviour entry 
> in ansible.cfg. 
> Or you can name the variable differently and then use the |union 
> filter in the task to aggregate them just for that task. 
>
>
>
> -- 
> Brian Coca 
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6e266253-e510-4bbd-a3a4-001d2c0505be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Same list from multiple vars-files consolidated

2015-01-07 Thread Sebastian Gumprich
Hello,

I have a list-item in the group-vars for "all" hosts:

"/etc/ansible/group_vars/all"

splunkforwarder_log_items:
  - app_name: var_messages
source: "/var/log/messages"



I also have the same list-item in another (narrowed down) group-var:

"/etc/ansible/group_vars/group_1"
splunkforwarder_log_items:
  - app_name: var_secure
source: "/var/log/secure"
index: "testindex"
sourcetype: linux_secure



Now I want to use both lists (or the conflated list) in the following task, 
so {{ item.app_name }} would be substituted with var_messages
 and var_secure from both lists.


- name: create input configuration
  template:
src=inputs_conf.j2
dest=/etc/apps/{{ item.app_name }}/local/inputs.conf
  with_items: splunkforwarder_log_items


Sadly, only the list from "group_1" is used.
Is there a way to conflate these lists / use both? Or am I doing something 
wrong?


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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/0e77bece-92e4-4957-ba72-0424dfc4040f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] use subelement-variables in templates

2014-08-13 Thread Sebastian Gumprich
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  > 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 ansible-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
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.


[ansible-project] use subelement-variables in templates

2014-08-12 Thread Sebastian Gumprich
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/6fa6b0f5-5bac-455c-bb8b-9cbd05ae5c76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.