This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Add verification tasks, always tag NAT gateways, and fix typos #57
Open
johnsimcall
wants to merge
4
commits into
jaredhocutt:master
Choose a base branch
from
johnsimcall:add-workers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ cluster_domain: "{{ cluster_name }}.{{ base_domain }}" | |
|
||
vpc_cidr: 172.31.0.0/16 | ||
vpc_subnet_bits: 24 | ||
route53_hosted_zone_name: "{{ cluster_domain }}" | ||
route53_hosted_zone_name: "{{ cluster_domain }}" #TODO: Does this need to have a trailing period? | ||
destroy_vpc: no | ||
|
||
openshift_version_major: "{{ openshift_version.split('.')[0] }}" | ||
|
@@ -21,7 +21,7 @@ ec2_instance_type_bootstrap: i3.large | |
ec2_instance_type_controller: m5.xlarge | ||
ec2_instance_type_worker: m5.large | ||
|
||
root_volume_size_bastion: 100 # +80GB to mirror the OLM images | ||
root_volume_size_bastion: 20 # 20GB base + 100GB to mirror OperatorHub | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did you mean for this to be |
||
root_volume_size_controller: 120 | ||
root_volume_size_worker: "{{ root_volume_size_controller }}" | ||
root_volume_size_bootstrap: "{{ root_volume_size_controller }}" | ||
|
101 changes: 101 additions & 0 deletions
101
playbooks/roles/infrastructure/tasks/aws/verifications.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
|
||
# If vpc_id is given, public_subnet_ids and private_subnet_ids are required | ||
- block: | ||
- name: Check if the user-defined vpc_id exists | ||
ec2_vpc_net_info: | ||
vpc_ids: "{{ vpc_id }}" | ||
|
||
- name: Fail when subnet_ids are undefined | ||
fail: | ||
msg: | | ||
ERROR: When vpc_id is provided a list of public and private subnet_ids | ||
must also be provided. For example: | ||
public_subnet_ids: | ||
- subnet-0123456789abcdef0 | ||
private_subnet_ids: | ||
- subnet-1234567890abcdef1 | ||
- subnet-234567890abcdef12 | ||
- subnet-34567890abcdef123 | ||
when: (public_subnet_ids is undefined) or (private_subnet_ids is undefined) | ||
Comment on lines
+9
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We'll need a bit more complex check because for a disconnected environment, there will not be any |
||
|
||
# TODO: Figure out how to make this task faster | ||
# This task will takes ~7 minutes if a non-existent subnet_id is given | ||
- name: Check if the user-defined subnets exist | ||
ec2_vpc_subnet_info: | ||
subnet_ids: "{{ public_subnet_ids + private_subnet_ids }}" | ||
register: r_verify_subnet_ids | ||
|
||
- name: Fail when all subnet_ids are not found | ||
fail: | ||
msg: | | ||
ERROR: Unable to find all user-defined subnets. Please make sure | ||
all of these subnet_ids exist. | ||
public_subnet_ids: "{{ public_subnet_ids }}" | ||
private_subnet_ids: "{{ private_subnet_ids }}" | ||
when: r_verify_subnet_ids.subnets | length != public_subnet_ids | length + private_subnet_ids | length | ||
when: vpc_id is defined | ||
|
||
|
||
# If rhcos_ami or rhel_ami is given, check that they exist in the region | ||
- name: Check if the RHCOS AMI exists | ||
ec2_ami_info: | ||
image_ids: "{{ rhcos_ami }}" | ||
when: rhcos_ami is defined | ||
|
||
- name: Check if the RHEL AMI exists | ||
ec2_ami_info: | ||
image_ids: "{{ rhel_ami }}" | ||
when: rhel_ami is defined | ||
|
||
|
||
# If keypair_path is given, check that it exists | ||
- block: | ||
- name: Check if bastion's keypair exists locally | ||
stat: | ||
path: "{{ keypair_path }}" | ||
register: r_keypair_path | ||
|
||
- name: Fail when bastion's private key is unavailable | ||
fail: | ||
msg: | | ||
ERROR: A private key (keypair_path) was defined, but not found. Please | ||
make sure that "{{ keypair_path }}" is available, or leave it undefined | ||
so that a new keypair can be auto-generated. | ||
when: r_keypair_path.stat.exists is false | ||
when: keypair_path is defined | ||
|
||
|
||
# If route53_hosted_zone_id is given, check that it exists | ||
- name: Check if the user-provided Route53 Hosted Zone exists | ||
route53_info: | ||
hosted_zone_id: "{{ route53_hosted_zone_id }}" | ||
hosted_zone_method: details | ||
query: hosted_zone | ||
when: route53_hosted_zone_id is defined | ||
|
||
# If route53_hosted_zone_id is not given AND cloud == "aws" | ||
# check that the default-named public Route53 Hosted Zone exists | ||
- block: | ||
- name: Get Route53 Hosted Zone list | ||
route53_info: | ||
query: hosted_zone | ||
max_items: "500" | ||
register: r_route53_hosted_zones | ||
failed_when: r_route53_hosted_zones.IsTruncated is true #Too many items to list | ||
|
||
- name: Fail when the default Route53 Hosted Zone (public) can't be found | ||
fail: | ||
msg: | | ||
ERROR: Unable to find public Route53 Hosted Zone named "{{ route53_hosted_zone_name }}" | ||
Please complete the prequisite steps in README.md and try again. | ||
when: r_route53_hosted_zones.HostedZones | | ||
selectattr('Name', 'match', route53_hosted_zone_name) | | ||
selectattr('Config.PrivateZone', 'match', 'False') | | ||
list | | ||
length != 1 | ||
when: | ||
- cloud == "aws" | ||
- route53_hosted_zone_id is undefined | ||
|
||
- debug: msg="All verification checks succeeded!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,23 +87,26 @@ | |
OpenShiftCluster: "{{ cluster_domain }}" | ||
OpenShiftClusterId: "{{ cluster_id }}" | ||
|
||
- name: Create NAT gateways | ||
ec2_vpc_nat_gateway: | ||
subnet_id: "{{ item }}" | ||
if_exist_do_not_create: yes | ||
loop: "{{ public_subnet_ids }}" | ||
register: r_create_nat_gateways | ||
|
||
# The ec2_vpc_nat_gateway does not allow you to add tags during creation, so | ||
# let's tag things after the fact | ||
- name: Add NAT gateway tags | ||
ec2_tag: | ||
resource: "{{ item.0.nat_gateway_id }}" | ||
tags: | ||
Name: "{{ cluster_id }}-{{ item.1 }}" | ||
OpenShiftCluster: "{{ cluster_domain }}" | ||
OpenShiftClusterId: "{{ cluster_id }}" | ||
loop: "{{ r_create_nat_gateways.results | zip(availability_zone_names) | list }}" | ||
- block: | ||
- name: Create NAT gateways | ||
ec2_vpc_nat_gateway: | ||
subnet_id: "{{ item }}" | ||
if_exist_do_not_create: yes | ||
loop: "{{ public_subnet_ids }}" | ||
register: r_create_nat_gateways | ||
|
||
# The ec2_vpc_nat_gateway doesn't allow you to add tags during creation, so | ||
# let's tag things after the fact (even if not all of the NGWs were created) | ||
always: | ||
- name: Add NAT gateway tags | ||
ec2_tag: | ||
resource: "{{ item.0.nat_gateway_id }}" | ||
tags: | ||
Name: "{{ cluster_id }}-{{ item.1 }}" | ||
OpenShiftCluster: "{{ cluster_domain }}" | ||
OpenShiftClusterId: "{{ cluster_id }}" | ||
loop: "{{ r_create_nat_gateways.results | zip(availability_zone_names) | list }}" | ||
when: item.0.success | ||
Comment on lines
+90
to
+109
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is pretty clever. I like it! |
||
|
||
- name: Create private subnets | ||
ec2_vpc_subnet: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No trailing period needed