Author: | Lester Wade |
---|
New in version 1.3.
Creates and removes tags from any EC2 resource. The resource is referenced by its resource id (e.g. an instance being i-XXXXXXX). It is designed to be used with complex args (tags), see the examples. This module has a dependency on python-boto.
parameter | required | default | choices | comments |
---|---|---|---|---|
aws_access_key | no | None | AWS access key. If not set then the value of the AWS_ACCESS_KEY environment variable is used. | |
aws_secret_key | no | None | AWS secret key. If not set then the value of the AWS_SECRET_KEY environment variable is used. | |
ec2_url | no | Url to use to connect to EC2 or your Eucalyptus cloud (by default the module will use EC2 endpoints). Must be specified if region is not used. If not set then the value of the EC2_URL environment variable, if any, is used. | ||
region | no | region in which the resource exists. | ||
resource | yes | The EC2 resource id. | ||
state | no | present |
|
Whether the tags should be present or absent on the resource. |
validate_certs | no | yes |
|
When set to "no", SSL certificates will not be validated for boto versions >= 2.6.0. (added in Ansible 1.5) |
Note
Requires boto
# Basic example of adding tag(s)
tasks:
- name: tag a resource
local_action: ec2_tag resource=vol-XXXXXX region=eu-west-1 state=present
args:
tags:
Name: ubervol
env: prod
# Playbook example of adding tag(s) to spawned instances
tasks:
- name: launch some instances
local_action: ec2 keypair={{ keypair }} group={{ security_group }} instance_type={{ instance_type }} image={{ image_id }} wait=true region=eu-west-1
register: ec2
- name: tag my launched instances
local_action: ec2_tag resource={{ item.id }} region=eu-west-1 state=present
with_items: ec2.instances
args:
tags:
Name: webserver
env: prod