Hi James, I used this syntax in my playbooks. But when you have to check several different conditions (and it's not only about installing software !) the "when:" becomes quite complicated. And I still think that simple kind of "abort_role" would make a code (especially in bigger playbooks/roles) much, much cleaner.
Anyway - thanks James - now I know I have no other options and have to stick with your way of doing it. Thanks again :-) Regards On Wednesday, September 17, 2014 5:53:40 PM UTC+1, James Cammarata wrote: > > In that case, you may wish to do something in your roles like: > > - name: check to see if something is already done > whatever: a=b c=d > register: is_done > > - name: include the rest of the role tasks from another file if the above > thing isn't done > include: role_tasks.yml > when: not is_done > > > > On Wed, Sep 17, 2014 at 10:02 AM, P <[email protected] <javascript:>> > wrote: > >> >> >> 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] <javascript:>. >> To post to this group, send email to [email protected] >> <javascript:>. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/ansible-project/523f8999-1639-4f0a-9e86-a847bc7833e5%40googlegroups.com >> >> <https://groups.google.com/d/msgid/ansible-project/523f8999-1639-4f0a-9e86-a847bc7833e5%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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/8e422bea-fb8b-4a6c-aefb-b7dde61095bc%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
