48
48
- Download filename of the SAP software.
49
49
required: false
50
50
type: str
51
- dest :
51
+ download_path :
52
52
description:
53
- - Destination folder.
53
+ - Destination folder path .
54
54
required: true
55
55
type: str
56
56
deduplicate:
78
78
community.sap_launchpad.sap_launchpad_software_center_download:
79
79
suser_id: 'SXXXXXXXX'
80
80
suser_password: 'password'
81
- softwarecenter_search_query :
81
+ search_query :
82
82
- 'SAPCAR_1324-80000936.EXE'
83
- dest : "/tmp/"
83
+ download_path : "/tmp/"
84
84
- name: Download using direct link and filename
85
85
community.sap_launchpad.software_center_download:
86
86
suser_id: 'SXXXXXXXX'
87
87
suser_password: 'password'
88
88
download_link: 'https://softwaredownloads.sap.com/file/0010000000048502015'
89
89
download_filename: 'IW_FNDGC100.SAR'
90
- dest : "/tmp/"
90
+ download_path : "/tmp/"
91
91
'''
92
92
93
93
RETURN = r'''
@@ -127,7 +127,7 @@ def run_module():
127
127
search_query = dict (type = 'str' , required = False , default = '' ),
128
128
download_link = dict (type = 'str' , required = False , default = '' ),
129
129
download_filename = dict (type = 'str' , required = False , default = '' ),
130
- dest = dict (type = 'str' , required = True ),
130
+ download_path = dict (type = 'str' , required = True ),
131
131
dry_run = dict (type = 'bool' , required = False , default = False ),
132
132
deduplicate = dict (type = 'str' , required = False , default = '' ),
133
133
search_alternatives = dict (type = 'bool' , required = False , default = False )
@@ -151,9 +151,9 @@ def run_module():
151
151
else :
152
152
query = None
153
153
154
+ download_path = module .params ['download_path' ]
154
155
download_link = module .params .get ('download_link' )
155
156
download_filename = module .params .get ('download_filename' )
156
- dest = module .params .get ('dest' )
157
157
dry_run = module .params .get ('dry_run' )
158
158
deduplicate = module .params .get ('deduplicate' )
159
159
search_alternatives = module .params .get ('search_alternatives' )
@@ -184,7 +184,7 @@ def run_module():
184
184
185
185
# Search for existing files using exact filename
186
186
filename = query if query else download_filename
187
- filename_exact = os .path .join (dest , filename )
187
+ filename_exact = os .path .join (download_path , filename )
188
188
result ['filename' ] = filename
189
189
190
190
if os .path .exists (filename_exact ):
@@ -193,10 +193,10 @@ def run_module():
193
193
module .exit_json (** result )
194
194
else :
195
195
# Exact file not found, search with pattern
196
- # pattern = dest + '/**/' + os.path.splitext(filename)[0] + '*' # old pattern
196
+ # pattern = download_path + '/**/' + os.path.splitext(filename)[0] + '*' # old pattern
197
197
filename_base = os .path .splitext (filename )[0 ]
198
198
filename_ext = os .path .splitext (filename )[1 ]
199
- filename_pattern = os .path .join (dest , "**" , filename_base + "*" + filename_ext )
199
+ filename_pattern = os .path .join (download_path , "**" , filename_base + "*" + filename_ext )
200
200
filename_similar = glob .glob (filename_pattern , recursive = True )
201
201
202
202
# Skip if similar files were found and search_alternatives was not set.
@@ -219,15 +219,15 @@ def run_module():
219
219
result ['filename' ] = download_filename
220
220
result ['alternative' ] = True
221
221
222
- filename_alternative_exact = os .path .join (dest , download_filename )
222
+ filename_alternative_exact = os .path .join (download_path , download_filename )
223
223
if os .path .exists (filename_alternative_exact ):
224
224
result ['skipped' ] = True
225
225
result ['msg' ] = f"Alternative file already exists: { download_filename } - original file { query } is not available to download"
226
226
module .exit_json (** result )
227
227
else :
228
228
filename_alternative_base = os .path .splitext (download_filename )[0 ]
229
229
filename_alternative_ext = os .path .splitext (download_filename )[1 ]
230
- filename_alternative_pattern = os .path .join (dest , "**" , filename_alternative_base + "*" + filename_alternative_ext )
230
+ filename_alternative_pattern = os .path .join (download_path , "**" , filename_alternative_base + "*" + filename_alternative_ext )
231
231
filename_alternative_similar = glob .glob (filename_alternative_pattern , recursive = True )
232
232
233
233
# Skip if similar files were found and search_alternatives was not set.
@@ -253,7 +253,7 @@ def run_module():
253
253
else :
254
254
module .fail_json (msg = "Download link {} is not available" .format (download_link ))
255
255
256
- download_software (download_link , download_filename , dest )
256
+ download_software (download_link , download_filename , download_path )
257
257
258
258
# Update final results json
259
259
result ['changed' ] = True
0 commit comments