If you ever want to skip a large number of tasks, usage of "group_by" can
easily do this.
- hosts: all
tasks:
- stat: path=/path/to/ruby
register: ruby
- group_by: key=ruby-{{ ruby.stat.exists }}
- hosts: ruby-False
tasks:
- ...
# or roles, etc
This is untested but that's the general pattern.
Also notice stat is a bit cleaner than "shell" above.
On Wed, Apr 9, 2014 at 7:16 PM, Rui Yang <[email protected]> wrote:
> Hi,
>
> Suppose I have a role called Ruby. I will
> 1. install build tools
> 2. download ruby source
> 3. compile
> 4. install
>
> Because it takes long time to do all these tings and I don't want to it it
> the expected Ruby already installed.
>
> How could I do it?
>
> I could do it using the "when" condition on every step. like the following:
>
> - name: check if ruby installed
> shell: ls /opt/rubies
> register: ruby_installed
>
> - name: install dependencies
> apt: name =....
> when: ruby_installed.stdout.find(ruby_full_version) == -1
>
> Wonder if there is any better solution? like a precondition for all the
> tasks in a role?
>
> Also I found it would be convenient if we have module like Java, Ruby to
> install various version of the packages. Like Chef they have Java cookbook.
>
> Any suggestion is really appreciated.
>
> Cheers,
> Rui
>
> --
> 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/8023f82f-a70e-4c74-935c-a3bef8b5abf8%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/8023f82f-a70e-4c74-935c-a3bef8b5abf8%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/CA%2BnsWgx%3Dwa56DSPyBgMHn-Hp2E3%3DUDW%2BwYwWxtCMjrj3Ab1%2BEg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.