-
Notifications
You must be signed in to change notification settings - Fork 2
/
ec2.yml
executable file
·51 lines (45 loc) · 1.44 KB
/
ec2.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
# The play operates on the local (Ansible control) machine.
---
- name: ML instance
hosts: localhost
remote_user: ec2-user
connection: local
gather_facts: false
vars:
ec2_region: "us-east-1a"
key_name: "id_rsa_macbook"
# instance_type: "c3.2xlarge"
instance_type: "c3.large"
ami_image: "ami-0b33d91d"
security_group: "launch-wizard-2"
spot_price: 0.02
spot_wait_timeout: 600
# ebs_volumes:
# - device_name: /dev/sdb
# volume_size: 10
# voume_type: gp2
# snapshot: snap-fe8a3c04
tasks:
- name: Launch instance
local_action: ec2 region="{{ ec2_region }}" key_name="{{ key_name }}" instance_type="{{ instance_type }}" image="{{ ami_image }}" wait="yes" count="1" group="{{ security_group }}" spot_price="{{spot_price | default(omit)}}" spot_wait_timeout="{{ spot_wait_timeout | default(omit)}}" volumes={{ ebs_volumes | default(omit)}}
register: ec2
- name: Add new instance to host group
add_host:
hostname: "{{ item.public_ip }}"
groupname: launched
with_items: "{{ ec2.instances }}"
- name: Wait for SSH to come up
wait_for:
host: "{{ item.public_dns_name }}"
port: 22
delay: 60
timeout: 900
state: started
with_items: "{{ ec2.instances }}"
- name: Configure instance(s)
hosts: launched
remote_user: ec2-user
gather_facts: True
roles:
- role: dev-env
- role: miniconda