Download file in a directory if directory is empty

asked 2018-05-11 01:27:43 -0500

Daizy gravatar image

Hello,

In my case, I am downloading latest version of UiPath file(mentioned the path of the file in variable $uipath_source) in directory - C:\temp\uipath.

download_file{ 'download_uipath':
                      url => $uipath_source,
                destination_directory => 'C:\\temp\\uipath\\',

However, I want to give a condition here, that if previous version of UiPath is already installed on C:\temp\uipath path, do not install latest version then, if uipath dir is empty only then install.

i.e. if below mentioned .msi files are already there in C:\temp\uipath, do not install anything, uipath dir should be empty for installing latest version.

--> UiPathStudio-2016.2.6274.msi --> UiPathStudio-2017.1.msi

I tried to give this condition -- onlyif => 'test ! -d C:\temp\uipath=="" ', but I am getting an error for this,

C:\Users\tankaur>puppet agent -t

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Error while evaluating a Resource Statement, Download
_file[download_uipath]: has no parameter named 'onlyif' at /etc/puppetlabs/manifests/uipath.pp 
Error: Could not retrieve catalog; skipping run

Can anyone suggest what condition can I apply here?

edit retag flag offensive close merge delete

Comments

You'd have to either write a custom fact determining the directory's content state, or write an exec resource.

Kai Burghardt gravatar imageKai Burghardt ( 2018-05-11 06:46:00 -0500 )edit

I don't know what the 'download_file' resource is from or how it works, but if it is similar to the staging module, that has the ability to have a 'creates' indicator, where you could have the directory 'created' by the set of resources that downloads the file.

DarylW gravatar imageDarylW ( 2018-05-11 07:15:48 -0500 )edit