# skipping of instance-ids using with\_items in ansible playbook

**URL:** <https://forum.ansible.com/t/skipping-of-instance-ids-using-with-items-in-ansible-playbook/24220>\
**Category:** Ansible Project\
**Created:** [April 14, 2017, 6:41am UTC](https://forum.ansible.com/t/skipping-of-instance-ids-using-with-items-in-ansible-playbook/24220 "2017-04-14T06:41:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acharya\_tejaswi\_indu](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@acharya\_tejaswi\_indu](https://forum.ansible.com/u/acharya_tejaswi_indu)\
**Post date:** [April 14, 2017, 6:41am UTC](https://forum.ansible.com/t/skipping-of-instance-ids-using-with-items-in-ansible-playbook/24220/1 "2017-04-14T06:41:50Z")

</div>

Hi

I am trying to start the instances from a list of instances-ids using with\_items and when condition.I have created a databases with four columns consisting of instance-ids,start-time,end-time and instance-name.Now by using jinja2 templates in ansible i have assigned 4 columns into four arrays.In the playbook i took present time and when this present time equals to the start time in the databases then the instance ids that are assigned to that start time get to be started.The error here is that i was able to pass the instance-ids to ec2 modules but those getting skipped.Here i took from myvar1 to myvar4 for 4 arrays as i mentioned above. myvar5 and myvar6 for the start time and end time that is matching with present time.And the playbook is

---

<div class="post-metadata">

**Author:** ![Anderson\_Goulart](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@Anderson\_Goulart](https://forum.ansible.com/u/Anderson_Goulart)\
**Post date:** [April 14, 2017, 5:41pm UTC](https://forum.ansible.com/t/skipping-of-instance-ids-using-with-items-in-ansible-playbook/24220/2 "2017-04-14T17:41:35Z")

</div>

Hi,

If it is skipping, the when clause is false. Couldn’t understand why do you need this when clause and why you are trying to convert to ‘int’… could you explain?

// Anderson

---

<div class="post-metadata">

**Author:** ![acharya\_tejaswi\_indu](https://avatars.discourse-cdn.com/v4/letter/a/41988e/32.png) [@acharya\_tejaswi\_indu](https://forum.ansible.com/u/acharya_tejaswi_indu)\
**Post date:** [April 18, 2017, 2:21pm UTC](https://forum.ansible.com/t/skipping-of-instance-ids-using-with-items-in-ansible-playbook/24220/3 "2017-04-18T14:21:51Z")

</div>

Hi,

yes,what you said is right.I resolved that problem.Instead of that ec2 instance module.I tried starting instances with at module.

Instead of that ec2 instance module i used

- at:  
command: “aws ec2 start-instances --instance-ids ‘{{item}}’”  
count: 1  
units: minutes  
state: present  
with\_items: “{{myvar5.split(\n)}}”

It is working good now.
