# ec2.py says I'm not being idempotent

**URL:** <https://forum.ansible.com/t/ec2-py-says-im-not-being-idempotent/15674>\
**Category:** Ansible Project\
**Tags:** aws\
**Created:** [July 15, 2014, 10:59am UTC](https://forum.ansible.com/t/ec2-py-says-im-not-being-idempotent/15674 "2014-07-15T10:59:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [July 15, 2014, 10:59am UTC](https://forum.ansible.com/t/ec2-py-says-im-not-being-idempotent/15674/1 "2014-07-15T10:59:25Z")

</div>

This works on one computer just fine but even after a reinstall of ansible I’m still getting this error on my personal laptop.

`

- name: Launch instance  
local\_action: ec2  
key\_name={{ key\_name }}  
group={{ security\_group }}  
instance\_type={{ instance\_type }}  
image={{ image }}  
wait=true  
region={{ region }}  
instance\_tags=‘{“Name”:“wordpress”}’  
monitoring=no  
instance\_tags=‘Name=wordpress,Group=WP’  
id=wordpress  
register: ec2  
`

`  
TASK: [aws | Launch instance] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*

\<127.0.0.1\> REMOTE\_MODULE ec2 key\_name=wordpress group=wordpress instance\_type=m1.small image=ami-8997afe0 wait=true region=us-east-1 instance\_tags=‘{“Name”:“wordpress”}’ monitoring=no instance\_tags=‘Name=wordpress,Group=WP’ id=wordpress

\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, ‘mkdir -p $HOME/.ansible/tmp/ansible-tmp-1405421602.32-200027015393859 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1405421602.32-200027015393859 && echo $HOME/.ansible/tmp/ansible-tmp-1405421602.32-200027015393859’]

\<127.0.0.1\> PUT /var/folders/\_0/2zdl4\_9j5txg1fgs3glyfxp80000gn/T/tmpwu\_vPt TO /Users/davidneudorfer/.ansible/tmp/ansible-tmp-1405421602.32-200027015393859/ec2

\<127.0.0.1\> EXEC [‘/bin/sh’, ‘-c’, u’LANG=C LC\_CTYPE=C /Users/davidneudorfer/Git/ansible-venv2/bin/python /Users/davidneudorfer/.ansible/tmp/ansible-tmp-1405421602.32-200027015393859/ec2; rm -rf /Users/davidneudorfer/.ansible/tmp/ansible-tmp-1405421602.32-200027015393859/ \>/dev/null 2\>&1’]

failed: [localhost → 127.0.0.1] =\> {“failed”: true}

msg: Instance creation failed =\> IdempotentParameterMismatch: Arguments on this idempotent request are inconsistent with arguments used in previous request(s).

FATAL: all hosts have already failed – aborting

`

---

<div class="post-metadata">

**Author:** ![david.neudorfer](https://avatars.discourse-cdn.com/v4/letter/d/b38774/32.png) [@david.neudorfer](https://forum.ansible.com/u/david.neudorfer)\
**Post date:** [July 15, 2014, 12:19pm UTC](https://forum.ansible.com/t/ec2-py-says-im-not-being-idempotent/15674/2 "2014-07-15T12:19:56Z")

</div>

Back at my work computer now and it fails here as well.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 15, 2014, 3:37pm UTC](https://forum.ansible.com/t/ec2-py-says-im-not-being-idempotent/15674/3 "2014-07-15T15:37:06Z")

</div>

That’s a really confusing error message from AWS.

Possibly helpful? [http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run\_Instance\_Idempotency.html](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html)

---

<div class="post-metadata">

**Author:** ![jonathan.hle](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@jonathan.hle](https://forum.ansible.com/u/jonathan.hle)\
**Post date:** [March 24, 2015, 5:43pm UTC](https://forum.ansible.com/t/ec2-py-says-im-not-being-idempotent/15674/4 "2015-03-24T17:43:00Z")

</div>

> I just ran into this error too. It has to do with the “id=wordpress” in your task - see: [http://ansible.sivel.net/docs/ec2\_module.html](http://ansible.sivel.net/docs/ec2_module.html)

id - identifier for this instance or set of instances, so that the module will be idempotent with respect to EC2 instances. This identifier is valid for at least 24 hours after the termination of the instance, and should not be reused for another call later on. For details, see the description of client token at [http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run\_Instance\_Idempotency.html](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html).

I’m finding that the “id” is valid for a LOT more than 24 hours for me. This is a pain since I’m destroying and recreating instances with the same name.

Instead of “id”, just use something like the following to maintain the number of boxes you want/ID the boxes:

instance\_tags:  
Name: “{{ prefix }}\_jumpbox”  
exact\_count: 1  
count\_tag:  
Name: “{{ prefix }}\_jumpbox”

Best,

Jonathan
