Skip to content

Commit 14c904b

Browse files
authored
Add GCP region zones to CDP Env creation (#143)
* Add GCP region zones to CDP ENV creation * Fix ternary check of AZ array Signed-off-by: Webster Mudge <[email protected]>
1 parent 34bb9d2 commit 14c904b

File tree

4 files changed

+23
-3
lines changed

4 files changed

+23
-3
lines changed

docs/configuration.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ env:
245245
enable_raz:
246246
gcp:
247247
auto_enable_services:
248+
availability_zones:
248249
manage_identities:
249250
bindings:
250251
cross_account:

roles/platform/defaults/main.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,6 @@ plat__aws_storage_suffix: "{{ env.aws.storage.suffix | defau
120120
plat__aws_role_tags: "{{ env.aws.role.tags | default({}) }}"
121121
plat__aws_policy_tags: "{{ env.aws.policy.tags | default({}) }}"
122122
plat__aws_storage_tags: "{{ env.aws.storage.tags | default({}) }}"
123-
plat__aws_vpc_id: "{{ common__aws_vpc_id }}"
124-
plat__aws_public_subnet_ids: "{{ common__aws_public_subnet_ids }}"
125-
plat__aws_private_subnet_ids: "{{ common__aws_private_subnet_ids }}"
126123

127124
plat__aws_xaccount_suffix: "{{ env.aws.role.label.cross_account | default(common__xaccount_suffix) }}"
128125
plat__aws_idbroker_suffix: "{{ common__aws_idbroker_suffix }}"
@@ -150,6 +147,8 @@ plat__aws_policy_urls: "{{ plat__aws_policy_urls_default
150147
plat__gcp_project: "{{ common__gcp_project }}"
151148
plat__gcp_subnet_id: "{{ common__gcp_subnet_id }}"
152149

150+
plat__gcp_availability_zones: "{{ env.gcp.availability_zones | default([]) }}"
151+
153152
plat__gcp_role_suffix: "{{ env.gcp.role.suffix | default(common__role_suffix) }}"
154153
plat__gcp_storage_suffix: "{{ env.gcp.storage.suffix | default(common__storage_suffix) }}"
155154

roles/platform/tasks/initialize_setup_gcp.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,25 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17+
- name: Discover available zones for GCP region
18+
block:
19+
- name: Fetch list of availability zones filtered by region
20+
ansible.builtin.command: >
21+
gcloud compute zones list --filter region={{ plat__region }} --format json
22+
register: __gcp_availability_zones_info
23+
24+
- name: Set fact for GCP availability zones
25+
ansible.builtin.set_fact:
26+
plat__gcp_availability_zones_discovered: "{{ __gcp_availability_zones_info.stdout | from_json | map(attribute='name') | list }}"
27+
28+
- name: Confirm availability zone access for CDP Environment
29+
when: plat__gcp_availability_zones | length > 0
30+
ansible.builtin.assert:
31+
that:
32+
- plat__gcp_availability_zones is subset(plat__gcp_availability_zones_discovered)
33+
fail_msg: "The following zone(s) are not available in region '{{ plat__region }}': {{ plat__gcp_availability_zones | difference(plat__gcp_availability_zones_discovered) | join(', ') }}"
34+
quiet: yes
35+
1736
# https://docs.cloudera.com/management-console/cloud/requirements-gcp/topics/mc-gcp_apis.html
1837
- name: Ensure Google Services Enabled
1938
when: plat__gcp_enable_services | bool

roles/platform/tasks/setup_gcp_env.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@
3434
tags: "{{ plat__tags }}"
3535
freeipa:
3636
instanceCountByGroup: "{{ plat__env_freeipa }}"
37+
zones: "{{ (plat__gcp_availability_zones | length > 0) | ternary(plat__gcp_availability_zones, omit) }}"

0 commit comments

Comments
 (0)