-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathec2-creation.yml
More file actions
57 lines (53 loc) · 1.45 KB
/
ec2-creation.yml
File metadata and controls
57 lines (53 loc) · 1.45 KB
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
54
55
56
57
---
- hosts: server
tasks:
- name: Setting up the Security Group for new instance
ec2_group:
name: Ansible_Security_Group_AWS
description: Allowing Traffic on port 22 and 80
region: ap-southeast-1
rules:
- proto: tcp
from_port: 80
to_port: 80
cidr_ip: 0.0.0.0/0
- proto: tcp
from_port: 22
to_port: 22
cidr_ip: 0.0.0.0/0
- proto: icmp
from_port: -1
to_port: -1
cidr_ip: 0.0.0.0/0
rules_egress:
- proto: all
cidr_ip: 0.0.0.0/0
vpc_id: vpc-d8826ebd
- name: Provision EC2 instance
ec2:
key_name: AWS-Ansible
region: ap-southeast-1
instance_type: t2.micro
image: ami-67a6e604
wait: yes
wait_timeout: 500
count: 1
instance_tags:
Name: AWS-Ansible
volumes:
- device_name: /dev/xvda
volume_type: gp2
volume_size: 8
monitoring: yes
vpc_subnet_id: subnet-18e7fa93
assign_public_ip: yes
group: Ansible_Security_Group_AWS
register: ec2
- name: Wait for SSH to come up
wait_for:
host: "{{ item.public_dns_name }}"
port: 22
delay: 60
timeout: 320
state: started
with_items: "{{ ec2.instances }}"