summaryrefslogtreecommitdiffstats
path: root/roles/openshift_aws/tasks/security_group.yml
blob: 0568a01900ccb71bf26483a3b84349725beb89f0 (plain)
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
---
- name: Fetch the VPC for the vpc.id
  ec2_vpc_net_facts:
    region: "{{ openshift_aws_region }}"
    filters:
      "tag:Name": "{{ openshift_aws_clusterid }}"
  register: vpcout

- name: create the node group sgs
  oo_ec2_group:
    name: "{{ item.value.name}}"
    description: "{{ item.value.desc }}"
    rules: "{{ item.value.rules if 'rules' in item.value else [] }}"
    region: "{{ openshift_aws_region }}"
    vpc_id: "{{ vpcout.vpcs[0].id }}"
  with_dict: "{{ openshift_aws_node_security_groups }}"

- name: create the k8s sgs for the node group
  oo_ec2_group:
    name: "{{ item.value.name }}_k8s"
    description: "{{ item.value.desc }} for k8s"
    region: "{{ openshift_aws_region }}"
    vpc_id: "{{ vpcout.vpcs[0].id }}"
  with_dict: "{{ openshift_aws_node_security_groups }}"
  register: k8s_sg_create

- name: tag sg groups with proper tags
  ec2_tag:
    tags: "{{ openshift_aws_security_groups_tags }}"
    resource: "{{ item.group_id }}"
    region: "{{ openshift_aws_region }}"
  with_items: "{{ k8s_sg_create.results }}"