Am Dienstag, 5. November 2013 17:43:54 UTC+1 schrieb Michel Blanc:
>
> Fellows,
>
> I trying to wrap my head around a simple problem.
> I have a playbook (role) that installs ruby with rbenv.
> Actually, it uses ruby.version host/group variable to install the
> correct ruby version :
>
> group_vars/some_servers_that_wants_ruby.yml :
> ---
> ruby:
> version: 1.9.3-p448
>
>
> However, I would like to change it so it can install several rubies on
> target servers, using :
>
> group_vars/some_servers_that_wants_ruby.yml :
> ---
> ruby:
> versions:
> - 1.9.3-p448
> - 2.0.0-p247
>
> The easiest way to achieve this would be to do :
>
> - hosts: some_servers_that_wants_ruby
> roles:
> - { role: ruby, version: "{{ item }}",
> with_items: ruby.versions }
>
> However, roles 'looping' seems to be bad : I get a deprecation warning
> ("[DEPRECATION WARNING]: include + with_items is an unsupported feature").
>
> Of course, I could have a playbook that would do :
>
> - hosts: some_servers_that_wants_ruby
> roles:
> - { role: ruby, version: "1.9.3-p448" }
> - [ role: ruby, version: "2.0.0-p247" }
>
> However, I really like to keep variables in host/groups_vars, and logic
> in the playbooks. This yields more generic and reusable playbooks, and
> doesn't require to write a playbook for specific hosts or groups. It is
> also much simpler since you know that what you're looking for is in
> host_vars or group_vars.
>
> Looping in the role tasks is not really an option : the tasks are
> somewhat complicated and require many (ordered) steps that wouldn't play
> nice using with_items on a per-task basis.
>
> Is there any way to achieve this ?
>
> Thanks,
>
> M
> --
> Michel Blanc
> { :github => "@leucos", :twitter => "@b9m", :gpg => "0X24B35C22" }
>
I just had the same problem. But since your post is a few years old, I
wondered if there might be a better solution by now. If there isn't, I'll
try the "hack" :D.
Thanks!
--
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/3c82e879-5189-4ddf-b9a3-0280ddbdbab0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.