Hi,


I want to use logentries to forward important log files. Most servers have 
the same files, but there are some which are specific based on which 
services are running. So I figured out one way to do this by using 
with_items like the example below, but I'm not sure if this is considered a 
good practice. The programmer in me instinctively wanted to define a 
variable in group_vars/all and append to it (like a "subclass") in 
group_vars/my_custom_server but that doesn't seem to be possible(?).


Or should I just create one task for the generic case and another task for 
the more specific one?


What's the idiomatic way to do this in ansible?


-Tore



---

- hosts: all


  vars:

  - has_particular_file: no # or yes; to see the different behaviour


  tasks:

  - name: Test

    action: debug msg="{{ item.file }}"

    with_items:

    - { file: /var/log/foo.log }

    - { file: /var/log/bar.log }

    - { file: /var/log/particular.log, cond: "{{ has_particular_file }}" }

    when: item.cond is not defined or item.cond|bool

-- 
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/62451252-1540-483f-988a-d6c1f799f800%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to