-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchuck-demo.yml
53 lines (44 loc) · 1.67 KB
/
chuck-demo.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
---
# Example Ansible Playbook to deploy a simple HTML5 application on AWS.
#
# Documentation:
# - EC2: http://docs.ansible.com/ansible/ec2_module.
# - ELB: http://docs.ansible.com/ansible/ec2_elb_lb_module.html
# - EC2_ELB: http://docs.ansible.com/ansible/ec2_elb_module.html
# - Aurthorized Keys: http://docs.ansible.com/ansible/authorized_key_module.html
# - add_hosts: http://docs.ansible.com/ansible/add_host_module.html
#
# Application: https://github.com/pixelsign/html5-device-mockups
#
- hosts: localhost
roles:
- stack-creator # Creates the stack for us
tasks:
# Add the nginx EC2 address - will export temporary EC2 addresses below {instance_name}.server
- include: roles/common/ec2_address.yml
vars:
instance_name: chuck-demo-nginx
ssh_name: chuck-demo
ssh_location: /Users/charlesrice/.ssh/
- name: Add SSH key for configuration connections
authorized_key: user=charlesrice key="{{ lookup('file', '/Users/charlesrice/.ssh/id_rsa.pub') }}"
# "Setup the nginx EC2 instance
- hosts: chuck-demo-nginx.server
remote_user: root
roles:
- nginx
# Print information in the terminal
- hosts: localhost
vars:
- elb_name_tag: chuck-demo-elb
tasks:
- name: Getting ELB information...
shell: aws elb describe-load-balancers --load-balancer-name {{ elb_name_tag }}
changed_when: False
register: instance_info
- name: Getting Public DNS for ELB...
shell: echo {{ (instance_info.stdout|from_json).LoadBalancerDescriptions[0].CanonicalHostedZoneName }}
changed_when: False
register: address
- name: Printing...
debug: msg="DONE! Access the stack at --> {{address.stdout}}"