Skip to content

Commit 60113ee

Browse files
committed
Updates to authz setup and teardown for deleting custom role, and scoping ad app down to the rg
Signed-off-by: Chris Perro <cmperro@gmail.com>
1 parent a4d8a45 commit 60113ee

File tree

4 files changed

+12
-54
lines changed

4 files changed

+12
-54
lines changed

roles/platform/defaults/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,8 @@ plat__azure_metagroup_name: "{{ common__azure_metagroup_name }
168168
plat__azure_storage_name: "{{ common__azure_storage_name }}"
169169

170170
plat__azure_consistency_wait: "{{ env.azure.app.wait | default(30) }}"
171-
plat__azure_xaccount_use_custom_role: "{{ env.azure.app.use_custom_role | default(False) }}"
171+
plat__azure_xaccount_use_custom_role: "{{ env.azure.use_custom_role | default(False) }}"
172+
plat__azure_xaccount_rg_scope: "{{ env.azure.rg_scope | default(False) }}"
172173
plat__azure_single_resource_group: "{{ env.azure.single_resource_group | default(False) }}"
173174
plat__azure_xaccount_app_name: "{{ env.azure.app.name | default([plat__namespace, plat__azure_xaccount_suffix, plat__azure_app_suffix] | join('-')) }}"
174175
plat__azure_xaccount_role_name: "{{ env.azure.role.name.cross_account | default([plat__namespace, plat__azure_xaccount_suffix, plat__azure_role_suffix] | join('-')) }}"

roles/platform/tasks/setup_azure_authz.yml

Lines changed: 2 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,15 @@
4444
- name: Wait for consistency
4545
ansible.builtin.pause:
4646
seconds: "{{ plat__azure_consistency_wait }}"
47-
48-
- name: Dump MetaGroup URI
49-
ansible.builtin.debug:
50-
msg: Dumping... {{ plat__azure_metagroup_uri }}
5147

52-
# Owner role is required for DWX if you are thinking of modifying this task
5348
- name: Request Azure Cross Account App Creation
5449
no_log: True
5550
register: __azure_xaccount_app_info
5651
command: >
5752
az ad sp create-for-rbac
5853
--name {{ plat__azure_xaccount_app_name }}
5954
--role {{ plat__azure_xaccount_use_custom_role | ternary(__azure_xaccount_role_info.id, plat__azure_roles.contrib) }}
60-
--scope {{ plat__azure_subscription_uri }}
61-
# --role {{ __azure_xaccount_role_info.id }}
62-
# --scopes {{ plat__azure_metagroup_uri }}
63-
# Bake ternary into the above
64-
65-
#- name: SLEEEP
66-
# command: >
67-
# sleep 180
55+
--scope {{ plat__azure_xaccount_rg_scope | ternary(plat__azure_metagroup_uri, plat__azure_subscription_uri) }}
6856
6957
- name: Register Azure Cross Account App info
7058
no_log: True
@@ -119,24 +107,6 @@
119107
application: "{{ plat__azure_xaccount_app_uuid }}"
120108
secret: "{{ __azure_xaccount_app_pword }}"
121109

122-
#Move Up
123-
#- name: Handle Azure Cross Account Role
124-
# register: __azure_xaccount_role_info
125-
# azure.azcollection.azure_rm_roledefinition: # This version fails idempotence if a description is set
126-
# state: present
127-
# name: "{{ plat__azure_xaccount_role_name }}"
128-
# assignable_scopes: "/subscriptions/{{ plat__azure_subscription_id }}"
129-
# permissions:
130-
# - actions: "{{ lookup('file', __azure_policy_document.dest ) | from_json | community.general.json_query('Actions') }}"
131-
# data_actions: "{{ lookup('file', __azure_policy_document.dest ) | from_json | community.general.json_query('DataActions') }}"
132-
# not_actions: "{{ lookup('file', __azure_policy_document.dest ) | from_json | community.general.json_query('NotActions') }}"
133-
# not_data_actions: "{{ lookup('file', __azure_policy_document.dest ) | from_json | community.general.json_query('NotDataActions') }}"
134-
135-
#Not Needed?
136-
#- name: Set Azure Cross Account Role URI
137-
# ansible.builtin.set_fact:
138-
# plat__azure_xaccount_role_uri: "{{ __azure_xaccount_role_info.id }}"
139-
140110
- name: Request creation of Azure Managed Identities
141111
when: ( __azure_identity_list_names is undefined ) or ( __azure_msi_item not in __azure_identity_list_names )
142112
loop_control:
@@ -148,7 +118,7 @@
148118
- "{{ plat__azure_datalakeadmin_identity_name }}"
149119
- "{{ plat__azure_log_identity_name }}"
150120
- "{{ plat__azure_ranger_audit_identity_name }}"
151-
#Dupe of Below?
121+
152122
- name: Wait for identities to be listed
153123
command: "az identity list -g {{ plat__azure_metagroup_name }}"
154124
register: __azure_identity_list
@@ -260,20 +230,6 @@
260230
scope: "{{ plat__azure_datapath_uri }}"
261231
assignee: "{{ __azure_ranger_audit_identity_uuid }}"
262232
desc: Assign Storage Blob Data Contributor Role to Ranger Role at Data Container level
263-
#- role: "{{ __azure_contributor_role_uri }}"
264-
# name: "{{ plat__azure_xaccount_contributor_assn_name }}"
265-
# scope: "{{ plat__azure_subscription_uri }}"
266-
# assignee: "{{ plat__azure_application_service_principal_objuuid }}"
267-
# desc: Assign top level Contributor Role to Cross Account App
268-
#- role: "{{ __azure_xaccount_role_uri }}"
269-
# name: "{{ plat__azure_xaccount_role_assn_name }}"
270-
# scope: "{{ plat__azure_subscription_uri }}"
271-
# assignee: "{{ plat__azure_application_service_principal_objuuid }}"
272-
# desc: Assign Cross Account Role to Cross Account App
273233
loop_control:
274234
loop_var: __azure_rl_assgn_item
275235
label: "{{ __azure_rl_assgn_item.desc }}"
276-
277-
#- name: SLEEEEEEEEEEP
278-
# command: >
279-
# sleep 1800

roles/platform/tasks/setup_azure_env.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
vpc_id: "{{ plat__vpc_name }}"
3131
tunnel: "{{ plat__tunnel }}"
3232
resource_gp: "{{ plat__azure_metagroup_name }}"
33-
use_single_resource_group: "{{ plat__azure_single_resource_group }}"
33+
use_single_resource_group: "{{ plat__azure_single_resource_group or plat__azure_xaccount_rg_scope | bool }}"
3434
subnet_ids: "{{ plat__azure_subnets }}"
3535
public_ip: "{{ plat__public_endpoint_access }}"
3636
tags: "{{ plat__tags }}"

roles/platform/tasks/teardown_azure_authz.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,16 @@
5555
when: plat__teardown_deletes_credential
5656
cloudera.cloud.env_cred:
5757
state: absent
58-
#cloud: "{{ plat__infra_type }}"
5958
name: "{{ plat__xacccount_credential_name }}"
60-
#subscription: "{{ plat__azure_subscription_id }}"
61-
#tenant: "{{ plat__azure_tenant_id }}"
62-
#application: "{{ plat__azure_xaccount_app_uuid }}"
63-
#secret: "{{ __azure_xaccount_app_pword }}"
6459

6560
- name: Tear down Azure AD App Registration
6661
when: plat__teardown_deletes_xaccount and ( plat__azure_xaccount_app_uuid is defined ) and ( plat__azure_xaccount_app_uuid | length > 0 )
6762
command: >
6863
az ad sp delete
69-
--id {{ plat__azure_application_service_principal_objuuid }}
64+
--id {{ plat__azure_application_service_principal_objuuid }}
65+
66+
- name: Tear down Custom Role
67+
when: plat__teardown_deletes_roles
68+
azure.azcollection.azure_rm_roledefinition:
69+
state: absent
70+
name: "{{ plat__azure_xaccount_role_name }}"

0 commit comments

Comments
 (0)