ansible/ansible — pull request #3299 by conradlee (2013-06-21 09:47:07+00:00)
Title: ec2 module: added support for attribute-based idempotency

As discussed on the mailing list and in the irc channel, the aws modules would ideally provide better support for idempotent operations.

This pull request implements extended support for idempotently provisioning ec2 instances using the ec2 module. The "id" option is extended. If id is set to "tags", "group", "group_id", or "image", then new instances will be provisioned only if there are not already count=N such instances with the specified attribute. For example, if

```yml
instance_tags: '{"db":"postgres"}'
id: tag
count: 5
idempotence_attribute: instance_tags
```
then new instances will be provisioned only if there are not already five instances with the tag db: postgres key-value pair.

An example is included in the EXAMPLES string.

Note that this pull request should not break backwards compatibility. I have tested this module and it appears to work, but someone needs to make sure that upon exiting, the module correctly indicates whether anything has changed.

(A similar pull request was submitted [here](https://github.com/ansible/ansible/pull/3249), but then closed.)