Skip to content

Instantly share code, notes, and snippets.

@tgerla
Created March 24, 2014 21:12
Show Gist options
  • Select an option

  • Save tgerla/9749281 to your computer and use it in GitHub Desktop.

Select an option

Save tgerla/9749281 to your computer and use it in GitHub Desktop.
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- name: Create the security group
ec2_group:
name: sshonly
description: SSH only
region: us-east-1
rules:
- proto: tcp
from_port: 22
to_port: 22
cidr_ip: 0.0.0.0/0
- name: create a fixed number of instances
# In this case, 5 instances with Name: webserver. if there are more than 5 running,
# the system will terminate the extras. If there are less, it'll launch more.
# There are a lot more options: http://docs.ansible.com/ec2_module.html
ec2:
key_name: mykey
instance_type: c1.medium
image: emi-40603AD1
wait: yes
group: sshonly
instance_tags:
Name: webserver
exact_count: 5
count_tag: Name
# After the instances are launched, you can switch to another playbook to manipulate them
# if you're using the ec2.py inventory source. If not, you can use add_host to add them
# to a temporary inventory group right in this playbook, and target them that way. See
# http://docs.ansible.com/guide_aws.html for more details.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment