[ansible-project] setting variables inside a loop

2017-05-07 Thread Pshem Kowalczyk
Hi,

I think I'm missing something obvious, so please point me in the right
direction (ansible 2.3).

- name: load and run services
  include_role:
name: "resource_{{ item.resource }}"
  vars:
resource: "{{ item }}"
  with_items:
- "{{ services }}"


How do I set the var ('resource') to something dependent on my item?
Whatever syntax I try I always end up with a literal and not the value. Is
setting variables using loop values not supported?

kind regards
Pshem

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEaZiRWsOg3h%2BU2J6sT5xf_-PhvEbUKk0oY7zpCagcTmKnr56g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] setting variables inside a loop

2017-05-11 Thread Brian Coca
you want:

loop_control:
   loop_var: resource


--
Brian Coca

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CACVha7cH76oU%3DhcTDc%3DV3ZOqDfw_deKRmTp6D6_NEe17Nk2sYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] setting variables inside a loop

2017-05-11 Thread Pshem Kowalczyk
Turns out it's actually a bug in 'include_role' - a bunch of tickets have
been opened about this. The general issue is that various types of
variables are not visible inside the 'include_role' scope. (see here:
https://github.com/ansible/ansible/issues?utf8=%E2%9C%93&q=is%3Aissue%20is%3Aopen%20include_role%20vars
 )

For now I've replaced the 'include_role' with 'include' and a bunch of
hacks to get the paths right.

kind regards
Pshem


On Fri, 12 May 2017 at 14:52 Brian Coca  wrote:

> you want:
>
> loop_control:
>loop_var: resource
>
>
> --
> Brian Coca
>
> --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/CACVha7cH76oU%3DhcTDc%3DV3ZOqDfw_deKRmTp6D6_NEe17Nk2sYA%40mail.gmail.com
> .
> 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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAEaZiRW3S%3DibrxwqkZOi64mheSAOi5xdBO9ahqDRYKWHh1OPeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.