Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ec2 subnet lookup pr 1.x #589

Merged
merged 10 commits into from
Feb 10, 2022
12 changes: 6 additions & 6 deletions roles/aws/aws_ec2_with_eip/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
ansible.builtin.set_fact:
_aws_ec2_with_eip_vpc_subnet_id: "{{ lookup('file', _ce_provision_data_dir + '/' + _aws_resource_name + '/ec2-subnet-id') }}"

# If we have no stored subnet ID and one has been set in variables this will override whatever might be looked up.
- name: Load defined subnet from variables.
ansible.builtin.set_fact:
_aws_ec2_with_eip_vpc_subnet_id: "{{ aws_ec2_with_eip.vpc_subnet_id }}"
when: ( aws_ec2_with_eip.vpc_subnet_id is defined and aws_ec2_with_eip.vpc_subnet_id | length > 0 and _aws_ec2_with_eip_vpc_subnet_id | length == 0 )

# If we have no stored subnet ID and vpc_name is defined we'll look up available subnets
- name: Gather VPC information.
amazon.aws.ec2_vpc_net_info:
Expand Down Expand Up @@ -66,12 +72,6 @@
with_random_choice: "{{ _aws_ec2_with_eip_subnets.subnets }}"
when: ( aws_ec2_with_eip.vpc_name is defined and aws_ec2_with_eip.vpc_name | length > 0 and _aws_ec2_with_eip_vpc_subnet_id | length == 0 )

# If we have no stored subnet ID and one has been set in variables this will override whatever might be looked up.
- name: Load defined subnet from variables.
ansible.builtin.set_fact:
_aws_ec2_with_eip_vpc_subnet_id: "{{ aws_ec2_with_eip.vpc_subnet_id }}"
when: ( aws_ec2_with_eip.vpc_subnet_id is defined and aws_ec2_with_eip.vpc_subnet_id | length > 0 and _aws_ec2_with_eip_vpc_subnet_id | length == 0 )

# Save the subnet ID to file.
- name: Save the subnet ID in the data directory.
ansible.builtin.template:
Expand Down