Debian Codegraph @

ansible_collections/community/aws/tests/integration/targets/networkfirewall/tasks/setup.yml

raw
1 ---
2 # The simplest form of rule group
3 - name: 'Create Rule Groups with minimal settings (Default order)'
4 networkfirewall_rule_group:
5 name: '{{ default_group_name }}-{{ item }}'
6 type: 'stateful'
7 capacity: '{{ rule_group_capacity }}'
8 rule_strings:
9 - 'pass tcp any any -> any any (sid:1000001;)'
10 register: default_groups
11 loop: '{{ range(0,3,1) | list }}'
12
13 # Store Group Names and ARNs for later
14 - set_fact:
15 default_group_names: >-
16 {{ default_groups.results
17 | map(attribute="rule_group")
18 | map(attribute="rule_group_metadata")
19 | map(attribute="rule_group_name") | list }}
20 default_group_arns: >-
21 {{ default_groups.results
22 | map(attribute="rule_group")
23 | map(attribute="rule_group_metadata")
24 | map(attribute="rule_group_arn") | list }}
25
26 - name: 'Pick 2 AZs available for use'
27 set_fact:
28 subnet_az_a_1: '{{ ec2_availability_zone_names[0] }}'
29 subnet_az_a_1a: '{{ ec2_availability_zone_names[0] }}'
30 subnet_az_a_2: '{{ ec2_availability_zone_names[1] }}'
31 subnet_az_a_3: '{{ ec2_availability_zone_names[2] }}'
32 subnet_az_b_1: '{{ ec2_availability_zone_names[0] }}'
33 subnet_az_b_2: '{{ ec2_availability_zone_names[1] }}'
34
35 - name: 'Create VPCs to attach to Firewall'
36 ec2_vpc_net:
37 cidr_block: '{{ item.cidr }}'
38 name: '{{ item.name }}'
39 loop:
40 - cidr: '{{ vpc_cidr_a }}'
41 name: '{{ vpc_name_a }}'
42 - cidr: '{{ vpc_cidr_b }}'
43 name: '{{ vpc_name_b }}'
44 register: create_vpcs
45
46 - set_fact:
47 vpc_id_a: '{{ vpc_a.id }}'
48 vpc_id_b: '{{ vpc_b.id }}'
49 vpc_owner_a: '{{ vpc_a.owner_id }}'
50 vpc_owner_b: '{{ vpc_b.owner_id }}'
51 vars:
52 vpc_a: '{{ create_vpcs.results[0].vpc }}'
53 vpc_b: '{{ create_vpcs.results[1].vpc }}'
54
55 - name: 'Create subnets'
56 ec2_vpc_subnet:
57 az: '{{ item.az }}'
58 cidr: '{{ item.cidr }}'
59 tags:
60 Name: '{{ item.name }}'
61 vpc_id: '{{ item.vpc_id }}'
62 loop:
63 - az: '{{ subnet_az_a_1 }}'
64 cidr: '{{ subnet_cidr_a_1 }}'
65 vpc_id: '{{ vpc_id_a }}'
66 name: '{{ subnet_name_a_1 }}'
67 - az: '{{ subnet_az_a_2 }}'
68 cidr: '{{ subnet_cidr_a_2 }}'
69 vpc_id: '{{ vpc_id_a }}'
70 name: '{{ subnet_name_a_2 }}'
71 - az: '{{ subnet_az_a_3 }}'
72 cidr: '{{ subnet_cidr_a_3 }}'
73 vpc_id: '{{ vpc_id_a }}'
74 name: '{{ subnet_name_a_3 }}'
75 - az: '{{ subnet_az_b_1 }}'
76 cidr: '{{ subnet_cidr_b_1 }}'
77 vpc_id: '{{ vpc_id_b }}'
78 name: '{{ subnet_name_b_1 }}'
79 - az: '{{ subnet_az_b_2 }}'
80 cidr: '{{ subnet_cidr_b_2 }}'
81 vpc_id: '{{ vpc_id_b }}'
82 name: '{{ subnet_name_b_2 }}'
83 - az: '{{ subnet_az_a_1a }}'
84 cidr: '{{ subnet_cidr_a_1a }}'
85 vpc_id: '{{ vpc_id_a }}'
86 name: '{{ subnet_name_a_1a }}'
87 register: create_subnets
88
89 - set_fact:
90 subnet_id_a_1: '{{ create_subnets.results[0].subnet.id }}'
91 subnet_id_a_2: '{{ create_subnets.results[1].subnet.id }}'
92 subnet_id_a_3: '{{ create_subnets.results[2].subnet.id }}'
93 subnet_id_b_1: '{{ create_subnets.results[3].subnet.id }}'
94 subnet_id_b_2: '{{ create_subnets.results[4].subnet.id }}'
95 subnet_id_a_1a: '{{ create_subnets.results[5].subnet.id }}'
96
97 - name: 'Create a simple firewall policy with `default` rule order'
98 networkfirewall_policy:
99 name: '{{ default_policy_name }}-{{ item }}'
100 stateful_rule_order: 'default'
101 stateful_rule_groups:
102 - '{{ default_group_names[(item)] }}'
103 state: present
104 register: default_policies
105 loop: '{{ range(0,3,1) | list }}'
106
107 # Store Group Names and ARNs for later
108 - set_fact:
109 default_policy_names: >-
110 {{ default_policies.results
111 | map(attribute="policy")
112 | map(attribute="policy_metadata")
113 | map(attribute="firewall_policy_name") | list }}
114 default_policy_arns: >-
115 {{ default_policies.results
116 | map(attribute="policy")
117 | map(attribute="policy_metadata")
118 | map(attribute="firewall_policy_arn") | list }}