On Wednesday, September 17, 2014 3:52:33 PM UTC+1, Patrick Ansible-ML wrote:
>
> On 17-09-14 14:15, P wrote: 
> > >     I would recommend changing the roles so that installation of new 
> >>     software is skipped (instead of failing) when the software is 
> already 
> >>     present... 
> > 
> > What do you mean by "skipped"  ? If I check at the top of a role that 
> > the software is installed 
> > how can I skip the rest of role ? 
>
> You could add a 'when:' clause in the tasks following the software 
> installation task to prevent them from running when the software is 
> already installed. The software installation task will need to set a 
> 'register:' clause with the result which can then be used by the 'when:' 
> clause in the following tasks. 
>
> http://docs.ansible.com/playbooks_conditionals.html 
>

I use it in my playbooks but when a role has many, many tasks you need to 
repeat
the same "when:" line in every task which is not very handy.

Also in more complicated cases your ansible code will go very unreadable.
Imagine you are going to install software related to hardware.
You don't need to install it under VM. So the most intuitive way
(at least for me ;-) ) would be:

if this is VM:
  abort role
if the software is installed:
  abort role
install software
...

-- 
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/523f8999-1639-4f0a-9e86-a847bc7833e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to