45 lines
1.8 KiB
YAML
45 lines
1.8 KiB
YAML
|
---
|
||
|
# This playbook demonstrates how to use the ansible cloudformation module to launch an AWS CloudFormation stack.
|
||
|
#
|
||
|
# This module requires that the boto python library is installed, and that you have your AWS credentials
|
||
|
# in $HOME/.boto
|
||
|
|
||
|
#The thought here is to bring up a bare infrastructure with CloudFormation, but use ansible to configure it.
|
||
|
#I generally do this in 2 different playbook runs as to allow the ec2.py inventory to be updated.
|
||
|
|
||
|
#This module also uses "complex arguments" which were introduced in ansible 1.1 allowing you to specify the
|
||
|
#Cloudformation template parameters
|
||
|
|
||
|
#This example launches a 3 node AutoScale group, with a security group, and an InstanceProfile with root permissions.
|
||
|
|
||
|
#If a stack does not exist, it will be created. If it does exist and the template file has changed, the stack will be updated.
|
||
|
#If the parameters are different, the stack will also be updated.
|
||
|
|
||
|
#CloudFormation stacks can take awhile to provision, if you are curious about its status, use the AWS
|
||
|
#web console or one of the CloudFormation CLI's.
|
||
|
|
||
|
#Example update -- try first launching the stack with 3 as the ClusterSize. After it is launched, change it to 4
|
||
|
#and run the playbook again.
|
||
|
|
||
|
- name: provision stack
|
||
|
hosts: localhost
|
||
|
connection: local
|
||
|
gather_facts: false
|
||
|
|
||
|
# Launch the cloudformation-example.json template. Register the output.
|
||
|
|
||
|
tasks:
|
||
|
- name: launch ansible cloudformation example
|
||
|
cloudformation: >
|
||
|
stack_name="ansible-cloudformation" state=present
|
||
|
region=us-east-1 disable_rollback=true
|
||
|
template=files/cloudformation-example.json
|
||
|
args:
|
||
|
template_parameters:
|
||
|
KeyName: jmartin
|
||
|
DiskType: ephemeral
|
||
|
InstanceType: m1.small
|
||
|
ClusterSize: 3
|
||
|
register: stack
|
||
|
- name: show stack outputs
|
||
|
debug: msg="My stack outputs are ${stack.stack_outputs}"
|