Am Freitag, 27. Januar 2017 08:50:52 UTC+1 schrieb Johannes Kastl:

> Add a when condition to only execute the task, if e.g. your variable 
> aptpackages is defined 
> when: 'aptpackages is defined' 
> (indentation equal to the name or apt lines) 
>
> Johannes 
>
>
As mentioned before, your answer helped a lot! Here is the solution I came 
up with.

- name: install apt packages
  apt: name={{ item }} state=latest
  delegate_to: "{{ groups.launched[0] }}"
  with_items: "{{ aptpackages }}"
  when: not((aptpackages is undefined) or (aptpackages is none) or 
(aptpackages | trim == ''))

I thought it would be more resilient to check if the variable is just 
undefined, none existing or empty. Because in all cases I want that action 
to be skipped. I tested all cases and it works for me. :)

I will also think about the other suggestion 
<http://www.dict.cc/englisch-deutsch/suggestion.html>s you made.

René

-- 
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/a81bdc3f-08d7-4da8-aaba-f7a7d53c86b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to