Skip to content

Commit 3c7739b

Browse files
cmperronmarian85
andauthored
RAZ support (#55)
* Add RAZ support * Update datalake config construction to handle the absence of GCP RAZ support Signed-off-by: Christopher Perro <cmperro@gmail.com> Co-authored-by: Nicolaie Marian <nmarian85@gmail.com>
1 parent 353805a commit 3c7739b

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

plugins/modules/datalake.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@
133133
default: 3600
134134
aliases:
135135
- polling_timeout
136+
raz:
137+
description:
138+
- Flag indicating if Ranger RAZ fine grained access should be enabled for the datalake
139+
type: bool
140+
required: False
141+
default: False
136142
extends_documentation_fragment:
137143
- cloudera.cloud.cdp_sdk_options
138144
- cloudera.cloud.cdp_auth_options
@@ -209,6 +215,10 @@
209215
sample:
210216
- AWS
211217
- AZURE
218+
enableRangerRaz:
219+
description: Whether or not RAZ is enabled
220+
returned: always
221+
type: bool
212222
clouderaManager:
213223
description: The Cloudera Manager details.
214224
returned: when supported
@@ -394,6 +404,7 @@ def __init__(self, module):
394404
self.delay = self._get_param('delay')
395405
self.timeout = self._get_param('timeout')
396406
self.force = self._get_param('force')
407+
self.raz = self._get_param("raz")
397408

398409
# Initialize the return values
399410
self.datalake = dict()
@@ -473,7 +484,7 @@ def process(self):
473484
def create_datalake(self, environment):
474485
self._validate_datalake_name()
475486

476-
payload = self._configure_payload()
487+
payload = self._configure_payload(environment)
477488

478489
if environment['cloudPlatform'] == 'AWS':
479490
if self.instance_profile is None or self.storage is None:
@@ -525,7 +536,7 @@ def delete_datalake(self):
525536
timeout=self.timeout
526537
)
527538

528-
def _configure_payload(self):
539+
def _configure_payload(self, environment):
529540
payload = dict(
530541
datalakeName=self.name,
531542
environmentName=self.environment,
@@ -537,6 +548,14 @@ def _configure_payload(self):
537548
if self.scale:
538549
payload.update(scale=self.scale)
539550

551+
if self.raz:
552+
if environment['cloudPlatform'] == 'AWS' or environment['cloudPlatform'] == 'AZURE':
553+
payload.update(enableRangerRaz=self.raz)
554+
else:
555+
self.module.fail_json(msg='GCP Datalakes do not currently support RAZ')
556+
else:
557+
payload.update(enableRangerRaz=self.raz)
558+
540559
if self.tags is not None:
541560
payload['tags'] = list()
542561
for k in self.tags:
@@ -576,6 +595,12 @@ def _reconcile_existing_state(self, existing):
576595
"need to change the tags, explicitly delete "
577596
"and recreate the Datalake.")
578597

598+
if self.raz:
599+
self.module.warn("Updating an existing Datalake's 'enableRangerRaz' "
600+
"directly is not supported at this time. If you "
601+
"need to change the enableRangerRaz, explicitly delete "
602+
"and recreate the Datalake.")
603+
579604
return mismatched
580605

581606
def _validate_datalake_name(self):
@@ -603,7 +628,8 @@ def main():
603628
force=dict(required=False, type='bool', default=False),
604629
wait=dict(required=False, type='bool', default=True),
605630
delay=dict(required=False, type='int', aliases=['polling_delay'], default=15),
606-
timeout=dict(required=False, type='int', aliases=['polling_timeout'], default=3600)
631+
timeout=dict(required=False, type='int', aliases=['polling_timeout'], default=3600),
632+
raz=dict(required=False, type="bool", default=False)
607633
),
608634
supports_check_mode=True
609635
)

0 commit comments

Comments
 (0)