Debian Codegraph @

ansible_collections/community/aws/tests/integration/targets/elb_instance/tasks/setup_vpc.yml

raw
1 ---
2 # SETUP: vpc, subnet, security group
3 - name: create a VPC to work in
4 ec2_vpc_net:
5 cidr_block: '{{ vpc_cidr }}'
6 state: present
7 name: '{{ vpc_name }}'
8 resource_tags:
9 Name: '{{ vpc_name }}'
10 register: setup_vpc
11
12 - name: create a subnet
13 ec2_vpc_subnet:
14 az: '{{ availability_zone_a }}'
15 tags: '{{ resource_prefix }}'
16 vpc_id: '{{ setup_vpc.vpc.id }}'
17 cidr: '{{ subnet_cidr_1 }}'
18 state: present
19 resource_tags:
20 Name: '{{ subnet_name_1 }}'
21 register: setup_subnet_1
22
23 - name: create a subnet
24 ec2_vpc_subnet:
25 az: '{{ availability_zone_b }}'
26 tags: '{{ resource_prefix }}'
27 vpc_id: '{{ setup_vpc.vpc.id }}'
28 cidr: '{{ subnet_cidr_2 }}'
29 state: present
30 resource_tags:
31 Name: '{{ subnet_name_2 }}'
32 register: setup_subnet_2
33
34 - name: create a security group
35 ec2_security_group:
36 name: '{{ sg_name_1 }}'
37 description: 'created by Ansible integration tests'
38 state: present
39 vpc_id: '{{ setup_vpc.vpc.id }}'
40 rules:
41 - proto: tcp
42 from_port: 22
43 to_port: 22
44 cidr_ip: '{{ vpc_cidr }}'
45 register: setup_sg_1
46
47 - name: create a security group
48 ec2_security_group:
49 name: '{{ sg_name_2 }}'
50 description: 'created by Ansible integration tests'
51 state: present
52 vpc_id: '{{ setup_vpc.vpc.id }}'
53 rules:
54 - proto: tcp
55 from_port: 22
56 to_port: 22
57 cidr_ip: '{{ vpc_cidr }}'
58 register: setup_sg_2
59
60 - name: store the IDs
61 set_fact:
62 subnet_a: "{{ setup_subnet_1.subnet.id }}"
63 subnet_b: "{{ setup_subnet_2.subnet.id }}"
64 sg_a: "{{ setup_sg_1.group_id }}"
65 sg_b: "{{ setup_sg_2.group_id }}"