order params, add missing tag param. update examples
This commit is contained in:
parent
29cfd80220
commit
3339749017
1 changed files with 54 additions and 16 deletions
|
@ -22,6 +22,12 @@ description:
|
||||||
- Creates, removes and lists 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.
|
- Creates, removes and lists 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.
|
||||||
version_added: "1.3"
|
version_added: "1.3"
|
||||||
options:
|
options:
|
||||||
|
region:
|
||||||
|
description:
|
||||||
|
- region in which the resource exists.
|
||||||
|
required: false
|
||||||
|
default: null
|
||||||
|
aliases: ['aws_region', 'ec2_region']
|
||||||
resource:
|
resource:
|
||||||
description:
|
description:
|
||||||
- The EC2 resource id.
|
- The EC2 resource id.
|
||||||
|
@ -35,12 +41,12 @@ options:
|
||||||
default: present
|
default: present
|
||||||
choices: ['present', 'absent', 'list']
|
choices: ['present', 'absent', 'list']
|
||||||
aliases: []
|
aliases: []
|
||||||
region:
|
tags:
|
||||||
description:
|
description:
|
||||||
- region in which the resource exists.
|
- a hash/dictionary of tags to add to the resource; '{"key":"value"}' and '{"key":"value","key":"value"}'
|
||||||
required: false
|
required: true
|
||||||
default: null
|
default: null
|
||||||
aliases: ['aws_region', 'ec2_region']
|
aliases: []
|
||||||
|
|
||||||
author: "Lester Wade (@lwade)"
|
author: "Lester Wade (@lwade)"
|
||||||
extends_documentation_fragment: aws
|
extends_documentation_fragment: aws
|
||||||
|
@ -50,25 +56,57 @@ EXAMPLES = '''
|
||||||
# Basic example of adding tag(s)
|
# Basic example of adding tag(s)
|
||||||
tasks:
|
tasks:
|
||||||
- name: tag a resource
|
- name: tag a resource
|
||||||
ec2_tag: resource=vol-XXXXXX region=eu-west-1 state=present
|
ec2_tag:
|
||||||
args:
|
region: eu-west-1
|
||||||
|
resource: vol-XXXXXX
|
||||||
|
state: present
|
||||||
tags:
|
tags:
|
||||||
Name: ubervol
|
Name: ubervol
|
||||||
env: prod
|
env: prod
|
||||||
|
|
||||||
# Playbook example of adding tag(s) to spawned instances
|
# Playbook example of adding tags to volumes on an instance
|
||||||
tasks:
|
tasks:
|
||||||
- name: launch some instances
|
- name: launch an instance
|
||||||
ec2: keypair={{ keypair }} group={{ security_group }} instance_type={{ instance_type }} image={{ image_id }} wait=true region=eu-west-1
|
ec2:
|
||||||
|
count_tags:
|
||||||
|
Name: dbserver
|
||||||
|
Env: production
|
||||||
|
exact_count: 1
|
||||||
|
group: "{{ security_group }}"
|
||||||
|
keypair: ""{{ keypair }}"
|
||||||
|
image: "{{ image_id }}"
|
||||||
|
instance_tags:
|
||||||
|
Name: dbserver
|
||||||
|
Env: production
|
||||||
|
instance_type: "{{ instance_type }}"
|
||||||
|
region: eu-west-1
|
||||||
|
volumes:
|
||||||
|
- device_name: /dev/xvdb
|
||||||
|
device_type: standard
|
||||||
|
volume_size: 10
|
||||||
|
delete_on_termination: true
|
||||||
|
wait: true
|
||||||
register: ec2
|
register: ec2
|
||||||
|
|
||||||
- name: tag my launched instances
|
- name: list the volumes for the instance
|
||||||
ec2_tag: resource={{ item.id }} region=eu-west-1 state=present
|
ec2_vol:
|
||||||
with_items: ec2.instances
|
instance: "{{ item.id }}"
|
||||||
args:
|
region: eu-west-1
|
||||||
|
state: list
|
||||||
|
with_items: ec2.tagged_instances
|
||||||
|
register: ec2_vol
|
||||||
|
|
||||||
|
- name: tag the volumes
|
||||||
|
ec2_tag:
|
||||||
|
region: eu-west-1
|
||||||
|
resource: "{{ item.id }}"
|
||||||
|
state: present
|
||||||
tags:
|
tags:
|
||||||
Name: webserver
|
Name: dbserver
|
||||||
env: prod
|
Env: production
|
||||||
|
with_subelements:
|
||||||
|
- ec2_vol.results
|
||||||
|
- volumes
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
Loading…
Reference in a new issue