# include\_role with\_sequence - why it runs all possible variants on all hosts?

**URL:** <https://forum.ansible.com/t/include-role-with-sequence-why-it-runs-all-possible-variants-on-all-hosts/26878>\
**Category:** Ansible Project\
**Created:** [March 1, 2018, 6:32pm UTC](https://forum.ansible.com/t/include-role-with-sequence-why-it-runs-all-possible-variants-on-all-hosts/26878 "2018-03-01T18:32:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jiri\_Novak](https://avatars.discourse-cdn.com/v4/letter/j/958977/32.png) [@Jiri\_Novak](https://forum.ansible.com/u/Jiri_Novak)\
**Post date:** [March 1, 2018, 6:32pm UTC](https://forum.ansible.com/t/include-role-with-sequence-why-it-runs-all-possible-variants-on-all-hosts/26878/1 "2018-03-01T18:32:42Z")

</div>

Hi,

I’ve stumbled upon strange behviour, any ideas what am I doing wrong?

let’s say I have variables like this:

hosts:  
hostnameA.tld:  
min\_id: 0  
max\_id: 5  
hostnameB.tld:  
min\_id: 6  
max\_id: 11

and then if I use them in task (templatE) with\_sequence, I get correct result

- name: ‘xxxxx’  
template:  
src: ‘service\_xx.conf.j2’  
dest: ‘{{ some\_dir }}/service\_{{ “%02d” | format(item | int) }}.conf’  
vars:  
service\_id: ‘{{ item }}’  
with\_sequence: start={{ hosts[inventory\_hostname][‘min\_id’] }} end={{ hosts[inventory\_hostname][‘max\_id’] }}

this will make files with 00-05 on hostnameA.tld and 06-11 on hostnameB.tld.

but if I use them with include\_role like this:

- name: ‘yyyyy’  
include\_role:  
name: ‘some-role’  
vars:  
service\_id: ‘{{ “%02d” | format(item | int) }}’  
with\_sequence: start={{ hosts[inventory\_hostname][‘min\_id’] }} end={{ hosts[inventory\_hostname][‘max\_id’] }}

the role is run with parameter 00-11 for both machines. Any idea why?

Thanks in advance,  
Gh.
