forked from siamaksade/openshift-jenkins-demo
-
Notifications
You must be signed in to change notification settings - Fork 3
/
ec2_sg_deploy.yml
44 lines (41 loc) · 1021 Bytes
/
ec2_sg_deploy.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
---
- name: Create EC2 Security Group
hosts: localhost
connection: local
gather_facts: false
become: false
tasks:
- name: Gather EC2 facts
ec2_instance_info:
region: "{{ ec2_region }}"
filters:
"tag:function": "{{ ec2_f5_tag }}"
register: ec2
tags:
- ec2-sg-deploy
- ec2_f5_facts
- name: Create Facts for F5 configuration
set_fact:
f5_private_ip: "{{ item['private_ip_address'] }}"
cacheable: true
loop: "{{ ec2.instances }}"
tags:
- ec2_sg_deploy
- ec2_sg_set_fact
- name: Create security group
ec2_group:
name: "{{ ec2_sg_name }}"
description: "JuiceShop Security Group"
region: "{{ ec2_region }}"
rules:
- proto: tcp
from_port: 22
to_port: 22
cidr_ip: 0.0.0.0/0
- proto: tcp
from_port: 3000
to_port: 3000
cidr_ip: "{{ hostvars['localhost']['f5_private_ip'] + '/32'}}"
tags:
- ec2_sg_deploy
- ec2_sg_create