1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
-
4
1
# Copyright 2023 Cloudera, Inc.
5
2
#
6
3
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -189,7 +186,12 @@ def run(self, tmp=None, task_vars=None):
189
186
# Compile the regexp
190
187
compiled = None
191
188
if regexp is not None :
192
- compiled = re .compile (regexp )
189
+ try :
190
+ compiled = re .compile (regexp )
191
+ except re .error as e :
192
+ raise AnsibleActionFail (
193
+ message = f"Regular expression, { regexp } , is invalid: { to_native (e )} "
194
+ )
193
195
194
196
# Assemble the src files into output file
195
197
with tempfile .NamedTemporaryFile (
@@ -231,15 +233,15 @@ def run(self, tmp=None, task_vars=None):
231
233
232
234
if assembled_checksum != dest_stat ["checksum" ]:
233
235
diff = {}
234
-
236
+
235
237
if self ._task .diff :
236
238
diff = self ._get_diff_data (dest , assembled .name , task_vars )
237
239
238
240
# Define a temporary remote path for the remote copy
239
241
remote_path = self ._connection ._shell .join_path (
240
242
self ._connection ._shell .tmpdir , "assembled_cluster_template"
241
243
)
242
-
244
+
243
245
# Transfer the file to the remote path
244
246
transfered = self ._transfer_file (assembled .name , remote_path )
245
247
@@ -262,7 +264,7 @@ def run(self, tmp=None, task_vars=None):
262
264
263
265
if diff :
264
266
copy .update (diff = diff )
265
-
267
+
266
268
result .update (copy )
267
269
else :
268
270
# Gather details on the existing file
@@ -271,7 +273,7 @@ def run(self, tmp=None, task_vars=None):
271
273
module_args = submodule_args ,
272
274
task_vars = task_vars ,
273
275
)
274
-
276
+
275
277
result .update (file )
276
278
except AnsibleAction as e :
277
279
result .update (e .result )
0 commit comments