Is this what "block" tasks are meant to handle?
On Friday, June 20, 2014 at 7:50:03 AM UTC-4, Tom Cannaerts wrote:
>
> I'm writing a playbook to create a number of solr cores, but I'm running
> into some issues.
>
> I started with a task file that would be included, but appearantly include
> and with_items isn't supported.
>
> The idea was, that for every core I would check that the base folder of
> the core existed. This result (stat) would be saved to a variable.
>
> - name: check for core existence
> stat: path=/usr/share/solr/live/solr/cores/{{ item.name }}
> register: st_cores
> with_items: solr_cores
>
> Then, to enumerate over it in later tasks, I could use the
> with_indexed_items and use a conditional when to exclude the cores that
> were already present
> eg:
>
> - name: Copy example core
> shell: cp -R /usr/share/solr/example/solr/collection1/conf/*
> /usr/share/solr/live/solr/cores/{{ item.0.name }}/conf/
> with_items: solr_cores
> when: not st_cores.results[{{ item.0 }}].stat.exists
>
> This works fine for most of the tasks, but I also have a number of tasks
> that use with_items themselves. I managed to combine them using
> with_nested, but I can't figure out how to include the conditional, as I
> don't have the index as with with_indexed_items
>
> eg.
> - name: Copy some files
> shell: cp /some/folder/{{ item[1] }} /usr/share/solr/cores/{{
> item[0].name }}/
> with_nested:
> - solr_cores
> - [ 'somefile.xml', 'anotherfile.xml', 'evenmorefiles.xml' ]
> when: not st_cores.results[{{ item[0].0 }}].stat.exists
>
> Basically, I can't check stat results, as I don't know the index of the
> current item in that array. Any ideas on how I can solve this? Either I
> need a way to be able to check for the file existance on some other way
> that does work with with_nested, or I need some sort of creative workaround
> for the include with_items problem.
>
>
--
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/c063cff3-fe15-4b04-94c0-98fb4a6b8742%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.