Hi, 

I've been restructuring my variables and ended up with something along the 
lines of:

files:
  - { src: 'a' }
  - { src: 'b' }

and a role that does:

- name: x
  template: 
    src: {{ item.src }}
    ...
    mode: {{ item.mode|default(0755) }} 
    owner: {{ item.owner|default(root) }}

This allows me to easily override the ownership/mode on a single file, yet 
have defaults for them if not specified, it also makes a step like this 
easily exchangeable with other roles (assuming you use the same variable 
structure there).
Anyway, what's problematic with such a layout is to determine whether a 
given file exists in a list of other files (for example for the sake of 
removing unmanaged files), think:

(Please bear in mind that I'm typing this from memory, so if I mixed up the 
syntax of a module, no need to point that out, just trying to illustrate my 
use-case)

- name: collect files..
  shell: blah
  register: found_files

- name: remove unmanaged
  file:
    path: {{ item }} 
    state: absent
  with_items:
    - found_files
  when: item not in files 

This is where it goes wrong, as files no longer is a flat list, but a list 
containing a dictionary; is there an easy way to say "when: item not in 
files.[*].src"? Or do I have to start using with_nested in this case 
(results in quite some overhead!!).

Thanks,
Nico 

-- 
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/ed55f042-9743-43b4-9e28-b6172f603022%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to