-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__create_SG_and_EC2.yml
51 lines (48 loc) · 1.4 KB
/
__create_SG_and_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
---
- name: create ec2 instances
hosts: localhost
connection: local
gather_facts: no
vars:
myport: 8080
region: us-east-1
subnet: subnet-0e11582cef5058fa5
sg: ansible_test
type: t2.micro
number: 1
tasks:
- name: create security group
ec2_group:
name: "{{ sg }}"
description: The webservers security group
region: "{{ region }}"
rules:
- proto: tcp
from_port: 22
to_port: 22
cidr_ip: 0.0.0.0/0
- proto: tcp
from_port: "{{ myport }}"
to_port: "{{ myport }}"
cidr_ip: 0.0.0.0/0
rules_egress:
- proto: all
cidr_ip: 0.0.0.0/0
- name: Lauching ec2 instance
ec2:
key_name: chavessh
instance_type: "{{ type }}"
region: "{{ region }}"
image: ami-0747bdcabd34c712a
wait: yes
wait_timeout: 500
group: "{{ sg }}"
count: "{{ number }}"
vpc_subnet_id: "{{ subnet }}"
assign_public_ip: yes
state: present
monitoring: no
instance_tags:
Name: AnsibleTest
Owner: AlanSilva
register: ec2_out