8
8
__metaclass__ = type
9
9
10
10
from ansible .plugins .action import ActionBase
11
+ import re
11
12
12
13
REGION_DS_KEYS = ["dfhgcd" , "dfhlcd" , "dfhintra" , "dfhlrq" , "dfhtemp" , "dfhauxt" , "dfhbuxt" , "dfhdmpa" , "dfhdmpb" , "dfhcsd" , "dfhstart" ]
13
14
CICS_DS_KEYS = ["sdfhload" , "sdfhauth" , "sdfhlic" ]
@@ -33,9 +34,7 @@ def _run(self, ds_name, module_name, cics_data_sets_required, tmp=None, task_var
33
34
try :
34
35
self ._process_module_args (
35
36
self .module_args ,
36
- self ._templar ,
37
37
ds_name ,
38
- task_vars ,
39
38
cics_data_sets_required ,
40
39
)
41
40
except (KeyError , ValueError ) as e :
@@ -56,17 +55,17 @@ def _run(self, ds_name, module_name, cics_data_sets_required, tmp=None, task_var
56
55
57
56
return return_structure
58
57
59
- def _process_module_args (self , module_args , _templar , ds_name , task_vars , cics_data_sets_required ):
60
- _process_module_args (module_args , _templar , ds_name , task_vars , cics_data_sets_required )
58
+ def _process_module_args (self , module_args , ds_name , cics_data_sets_required ):
59
+ _process_module_args (module_args , ds_name , cics_data_sets_required )
61
60
62
61
63
- def _process_module_args (module_args , _templar , ds_name , task_vars , cics_data_sets_required ):
64
- _process_region_data_set_args (module_args , _templar , ds_name , task_vars )
62
+ def _process_module_args (module_args , ds_name , cics_data_sets_required ):
63
+ _process_region_data_set_args (module_args , ds_name )
65
64
_process_data_set_unit_args (module_args )
66
65
_remove_region_data_set_args (module_args , ds_name )
67
66
68
67
if cics_data_sets_required :
69
- _process_libraries_args (module_args , _templar , task_vars , "cics_data_sets" , "sdfhload" )
68
+ _process_libraries_args (module_args , "cics_data_sets" , "sdfhload" )
70
69
_remove_cics_data_set_args (module_args , "sdfhload" )
71
70
else :
72
71
if module_args .get ("cics_data_sets" ):
@@ -102,7 +101,7 @@ def _remove_cics_data_set_args(module_args, ds_name):
102
101
del module_args ["cics_data_sets" ][cics_key ]
103
102
104
103
105
- def _process_region_data_set_args (module_args , _templar , ds_name , task_vars ):
104
+ def _process_region_data_set_args (module_args , ds_name ):
106
105
if not module_args .get ("region_data_sets" ):
107
106
raise KeyError ("Required argument region_data_sets not found" )
108
107
@@ -111,8 +110,6 @@ def _process_region_data_set_args(module_args, _templar, ds_name, task_vars):
111
110
module_args ["region_data_sets" ].update ({
112
111
ds_name : {
113
112
"dsn" : _template_dsn (
114
- _templar = _templar ,
115
- task_vars = task_vars ,
116
113
var_name = "data_set_name" ,
117
114
replace_val = ds_name .upper (),
118
115
template = module_args ["region_data_sets" ]["template" ],
@@ -140,12 +137,10 @@ def _validate_data_set_length(data_set):
140
137
raise ValueError ("Data set: {0} is longer than 44 characters." .format (data_set ))
141
138
142
139
143
- def _process_libraries_args (module_args , _templar , task_vars , lib_type , lib_ds_name ):
140
+ def _process_libraries_args (module_args , lib_type , lib_ds_name ):
144
141
if not _check_library_override (module_args , lib_type , lib_ds_name ):
145
142
if _check_template (module_args , lib_type ):
146
143
module_args [lib_type ][lib_ds_name ] = _template_dsn (
147
- _templar = _templar ,
148
- task_vars = task_vars ,
149
144
var_name = "lib_name" ,
150
145
replace_val = lib_ds_name .upper (),
151
146
template = module_args [lib_type ]["template" ],
@@ -155,14 +150,8 @@ def _process_libraries_args(module_args, _templar, task_vars, lib_type, lib_ds_n
155
150
return _validate_data_set_length (module_args [lib_type ][lib_ds_name ])
156
151
157
152
158
- def _template_dsn (_templar , task_vars , var_name , replace_val , template ):
159
- cpy = task_vars .copy ()
160
- cpy .update ({var_name : replace_val })
161
- return _templar .copy_with_new_env (
162
- variable_start_string = "<<" ,
163
- variable_end_string = ">>" ,
164
- available_variables = cpy ,
165
- ).do_template (template , overrides = dict (variable_start_string = "<<" , variable_end_string = ">>" ))
153
+ def _template_dsn (var_name , replace_val , template ):
154
+ return re .sub (f"<<\\ s*{ var_name } \\ s*>>" , replace_val , template )
166
155
167
156
168
157
def _check_template (module_args , arg_dict ):
0 commit comments