Misc EC2 doc tweaks.

pull/18777/head
Michael DeHaan 10 years ago committed by Matt Clay
parent ddc81c7b93
commit 590d20db24

@ -20,7 +20,6 @@ module: cloudformation
short_description: create a AWS CloudFormation stack short_description: create a AWS CloudFormation stack
description: description:
- Launches an AWS CloudFormation stack and waits for it complete. - Launches an AWS CloudFormation stack and waits for it complete.
version_added: "1.1"
options: options:
stack_name: stack_name:
description: description:
@ -98,17 +97,17 @@ EXAMPLES = '''
tasks: tasks:
- name: launch ansible cloudformation example - name: launch ansible cloudformation example
cloudformation: cloudformation:
stack_name="ansible-cloudformation" state=present stack_name: "ansible-cloudformation"
region=us-east-1 disable_rollback=true state: "present"
template=files/cloudformation-example.json region: "us-east-1 disable_rollback=true"
args: template: "files/cloudformation-example.json"
template_parameters: template_parameters:
KeyName: jmartin KeyName: "jmartin"
DiskType: ephemeral DiskType: "ephemeral"
InstanceType: m1.small InstanceType: "m1.small"
ClusterSize: 3 ClusterSize: 3
tags: tags:
Stack: ansible-cloudformation Stack: "ansible-cloudformation"
''' '''
import json import json

@ -17,10 +17,9 @@
DOCUMENTATION = ''' DOCUMENTATION = '''
--- ---
module: ec2 module: ec2
short_description: create, terminate, start or stop an instance in ec2, return instanceid short_description: create, terminate, start or stop an instance in ec2
description: description:
- Creates or terminates ec2 instances. When created optionally waits for it to be 'running'. This module has a dependency on python-boto >= 2.5 - Creates or terminates ec2 instances.
version_added: "0.9"
options: options:
key_name: key_name:
description: description:
@ -28,12 +27,6 @@ options:
required: false required: false
default: null default: null
aliases: ['keypair'] aliases: ['keypair']
id:
description:
- 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 U(http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html).
required: false
default: null
aliases: []
group: group:
description: description:
- security group (or list of groups) to use with the instance - security group (or list of groups) to use with the instance
@ -76,7 +69,7 @@ options:
aliases: [] aliases: []
image: image:
description: description:
- I(emi) (or I(ami)) to use for the instance - I(ami) ID to use for the instance
required: true required: true
default: null default: null
aliases: [] aliases: []
@ -94,7 +87,7 @@ options:
aliases: [] aliases: []
wait: wait:
description: description:
- wait for the instance to be in state 'running' before returning - wait for the instance to be 'running' before returning. Does not wait for SSH, see 'wait_for' example for details.
required: false required: false
default: "no" default: "no"
choices: [ "yes", "no" ] choices: [ "yes", "no" ]
@ -226,40 +219,40 @@ extends_documentation_fragment: aws
''' '''
EXAMPLES = ''' EXAMPLES = '''
# Note: None of these examples set aws_access_key, aws_secret_key, or region. # Note: These examples do not set authentication details, see the AWS Guide for details.
# It is assumed that their matching environment variables are set.
# Basic provisioning example # Basic provisioning example
- local_action: - ec2:
module: ec2
key_name: mykey key_name: mykey
instance_type: c1.medium instance_type: t2.micro
image: emi-40603AD1 image: ami-123456
wait: yes wait: yes
group: webserver group: webserver
count: 3 count: 3
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
# Advanced example with tagging and CloudWatch # Advanced example with tagging and CloudWatch
- local_action: - ec2:
module: ec2
key_name: mykey key_name: mykey
group: databases group: databases
instance_type: m1.large instance_type: t2.micro
image: ami-6e649707 image: ami-123456
wait: yes wait: yes
wait_timeout: 500 wait_timeout: 500
count: 5 count: 5
instance_tags: instance_tags:
db: postgres db: postgres
monitoring: yes monitoring: yes
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
# Single instance with additional IOPS volume from snapshot and volume delete on termination # Single instance with additional IOPS volume from snapshot and volume delete on termination
local_action: - ec2:
module: ec2
key_name: mykey key_name: mykey
group: webserver group: webserver
instance_type: m1.large instance_type: c3.medium
image: ami-6e649707 image: ami-123456
wait: yes wait: yes
wait_timeout: 500 wait_timeout: 500
volumes: volumes:
@ -270,10 +263,11 @@ local_action:
volume_size: 100 volume_size: 100
delete_on_termination: true delete_on_termination: true
monitoring: yes monitoring: yes
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
# Multiple groups example # Multiple groups example
local_action: - ec2:
module: ec2
key_name: mykey key_name: mykey
group: ['databases', 'internal-services', 'sshable', 'and-so-forth'] group: ['databases', 'internal-services', 'sshable', 'and-so-forth']
instance_type: m1.large instance_type: m1.large
@ -284,10 +278,11 @@ local_action:
instance_tags: instance_tags:
db: postgres db: postgres
monitoring: yes monitoring: yes
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
# Multiple instances with additional volume from snapshot # Multiple instances with additional volume from snapshot
local_action: - ec2:
module: ec2
key_name: mykey key_name: mykey
group: webserver group: webserver
instance_type: m1.large instance_type: m1.large
@ -300,21 +295,11 @@ local_action:
snapshot: snap-abcdef12 snapshot: snap-abcdef12
volume_size: 10 volume_size: 10
monitoring: yes monitoring: yes
# VPC example
- local_action:
module: ec2
key_name: mykey
group_id: sg-1dc53f72
instance_type: m1.small
image: ami-6e649707
wait: yes
vpc_subnet_id: subnet-29e63245 vpc_subnet_id: subnet-29e63245
assign_public_ip: yes assign_public_ip: yes
# Spot instance example # Spot instance example
- local_action: - ec2:
module: ec2
spot_price: 0.24 spot_price: 0.24
spot_wait_timeout: 600 spot_wait_timeout: 600
keypair: mykey keypair: mykey
@ -328,7 +313,6 @@ local_action:
# Launch instances, runs some tasks # Launch instances, runs some tasks
# and then terminate them # and then terminate them
- name: Create a sandbox instance - name: Create a sandbox instance
hosts: localhost hosts: localhost
gather_facts: False gather_facts: False
@ -340,13 +324,21 @@ local_action:
region: us-east-1 region: us-east-1
tasks: tasks:
- name: Launch instance - name: Launch instance
local_action: ec2 key_name={{ keypair }} group={{ security_group }} instance_type={{ instance_type }} image={{ image }} wait=true region={{ region }} ec2:
key_name: "{{ keypair }}"
group: "{{ security_group }}"
instance_type: "{{ instance_type }}"
image: "{{ image }}"
wait: true
region: "{{ region }}"
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
register: ec2 register: ec2
- name: Add new instance to host group - name: Add new instance to host group
local_action: add_host hostname={{ item.public_ip }} groupname=launched add_host: hostname={{ item.public_ip }} groupname=launched
with_items: ec2.instances with_items: ec2.instances
- name: Wait for SSH to come up - name: Wait for SSH to come up
local_action: wait_for host={{ item.public_dns_name }} port=22 delay=60 timeout=320 state=started wait_for: host={{ item.public_dns_name }} port=22 delay=60 timeout=320 state=started
with_items: ec2.instances with_items: ec2.instances
- name: Configure instance(s) - name: Configure instance(s)
@ -362,8 +354,7 @@ local_action:
connection: local connection: local
tasks: tasks:
- name: Terminate instances that were previously launched - name: Terminate instances that were previously launched
local_action: ec2:
module: ec2
state: 'absent' state: 'absent'
instance_ids: '{{ ec2.instance_ids }}' instance_ids: '{{ ec2.instance_ids }}'
@ -382,12 +373,13 @@ local_action:
region: us-east-1 region: us-east-1
tasks: tasks:
- name: Start the sandbox instances - name: Start the sandbox instances
local_action: ec2:
module: ec2
instance_ids: '{{ instance_ids }}' instance_ids: '{{ instance_ids }}'
region: '{{ region }}' region: '{{ region }}'
state: running state: running
wait: True wait: True
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
role: role:
- do_neat_stuff - do_neat_stuff
- do_more_neat_stuff - do_more_neat_stuff
@ -404,38 +396,40 @@ local_action:
region: us-east-1 region: us-east-1
tasks: tasks:
- name: Stop the sandbox instances - name: Stop the sandbox instances
local_action: ec2:
module: ec2
instance_ids: '{{ instance_ids }}' instance_ids: '{{ instance_ids }}'
region: '{{ region }}' region: '{{ region }}'
state: stopped state: stopped
wait: True wait: True
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
# #
# Enforce that 5 instances with a tag "foo" are running # Enforce that 5 instances with a tag "foo" are running
# (Highly recommended!)
# #
- local_action: - ec2:
module: ec2
key_name: mykey key_name: mykey
instance_type: c1.medium instance_type: c1.medium
image: emi-40603AD1 image: ami-40603AD1
wait: yes wait: yes
group: webserver group: webserver
instance_tags: instance_tags:
foo: bar foo: bar
exact_count: 5 exact_count: 5
count_tag: foo count_tag: foo
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
# #
# Enforce that 5 running instances named "database" with a "dbtype" of "postgres" # Enforce that 5 running instances named "database" with a "dbtype" of "postgres"
# #
- local_action: - ec2:
module: ec2
key_name: mykey key_name: mykey
instance_type: c1.medium instance_type: c1.medium
image: emi-40603AD1 image: ami-40603AD1
wait: yes wait: yes
group: webserver group: webserver
instance_tags: instance_tags:
@ -445,6 +439,8 @@ local_action:
count_tag: count_tag:
Name: database Name: database
dbtype: postgres dbtype: postgres
vpc_subnet_id: subnet-29e63245
assign_public_ip: yes
# #
# count_tag complex argument examples # count_tag complex argument examples

Loading…
Cancel
Save