working on aws still but deployment works
This commit is contained in:
+25
-2
@@ -12,8 +12,11 @@
|
||||
deployment_id: "{{ deployment_id | default('') }}"
|
||||
infra_name: "infra-{{ deployment_id }}"
|
||||
# Region settings
|
||||
split_regions: "{{ c2_region is defined and redirector_region is defined and c2_region != redirector_region }}"
|
||||
deployment_region: "{{ aws_region | default(aws_region_choices | random) }}"
|
||||
# Check if using split regions (C2 and redirector in different regions)
|
||||
split_regions: "{{ c2_region is defined and redirector_region is defined and c2_region != redirector_region }}"
|
||||
# Check if only deploying one component (C2 only or redirector only)
|
||||
single_component: "{{ c2_only | default(false) | bool or redirector_only | default(false) | bool }}"
|
||||
|
||||
tasks:
|
||||
- name: Validate AWS credentials
|
||||
@@ -26,6 +29,20 @@
|
||||
- name: Skip shared infrastructure if using split regions
|
||||
meta: end_play
|
||||
when: split_regions | bool
|
||||
|
||||
- name: Print infrastructure deployment info
|
||||
debug:
|
||||
msg: "Deploying shared infrastructure in {{ deployment_region }}"
|
||||
when: not split_regions | bool and not single_component | bool
|
||||
|
||||
- name: Check if deploying just C2 or just redirector
|
||||
debug:
|
||||
msg: "Skipping shared infrastructure for single component deployment ({{ 'C2 only' if c2_only | default(false) else 'Redirector only' }})"
|
||||
when: single_component | bool
|
||||
|
||||
- name: Skip shared infrastructure for single component deployment
|
||||
meta: end_play
|
||||
when: single_component | bool
|
||||
|
||||
- name: Create shared VPC
|
||||
amazon.aws.ec2_vpc_net:
|
||||
@@ -37,10 +54,12 @@
|
||||
deployment_id: "{{ deployment_id }}"
|
||||
state: present
|
||||
register: vpc_result
|
||||
when: not split_regions | bool and not single_component | bool
|
||||
|
||||
- name: Store shared VPC ID
|
||||
set_fact:
|
||||
shared_vpc_id: "{{ vpc_result.vpc.id }}"
|
||||
when: not split_regions | bool and not single_component | bool and vpc_result is defined
|
||||
|
||||
- name: Create internet gateway
|
||||
amazon.aws.ec2_vpc_igw:
|
||||
@@ -51,6 +70,7 @@
|
||||
Name: "{{ infra_name }}-igw"
|
||||
deployment_id: "{{ deployment_id }}"
|
||||
register: igw_result
|
||||
when: not split_regions | bool and not single_component | bool and shared_vpc_id is defined
|
||||
|
||||
- name: Create subnet
|
||||
amazon.aws.ec2_vpc_subnet:
|
||||
@@ -63,6 +83,7 @@
|
||||
Name: "{{ infra_name }}-subnet"
|
||||
deployment_id: "{{ deployment_id }}"
|
||||
register: subnet_result
|
||||
when: not split_regions | bool and not single_component | bool and shared_vpc_id is defined
|
||||
|
||||
- name: Create routing table
|
||||
amazon.aws.ec2_vpc_route_table:
|
||||
@@ -77,6 +98,7 @@
|
||||
subnets:
|
||||
- "{{ subnet_result.subnet.id }}"
|
||||
register: route_table_result
|
||||
when: not split_regions | bool and not single_component | bool and shared_vpc_id is defined and igw_result is defined and subnet_result is defined
|
||||
|
||||
- name: Write infrastructure info to state file
|
||||
copy:
|
||||
@@ -89,4 +111,5 @@
|
||||
"deployment_id": "{{ deployment_id }}"
|
||||
}
|
||||
dest: "infrastructure_state.json"
|
||||
mode: "0600"
|
||||
mode: "0600"
|
||||
when: not split_regions | bool and not single_component | bool and shared_vpc_id is defined and subnet_result is defined and igw_result is defined
|
||||
Reference in New Issue
Block a user