ec2.py says I'm not being idempotent

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

`

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

That’s a really confusing error message from AWS.

Possibly helpful? http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html

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

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.

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