skipping of instance-ids using with_items in ansible playbook

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

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

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.