how to unzip a file in Windows server

asked 2017-06-05 20:24:56 -0600

beebee gravatar image

I write my codes as below, but the .zip file can copy to $softwarehome, but can't extract to $boxsod_home.

 file { $box_sod_home:
    ensure  => "directory"
  file { "$software_home\\":
    source => "puppet:///modules/box_sod/",
    notify   => Exec["Extract"]

  exec { "Extract" :
    command  => "unzip.exe $software_home\\ -d $box_sod_home",
    #command  => "unzip.exe C:\\box_software\\ -d $box_sod_home",
    path     => $::path,
    unless   => "cmd.exe /c if exist \"$box_sod_home\" (exit /B 0) else (exit /B 1)",
    require  => File[$software_home],
    refreshonly => true

I can manually run the unzip command.

The puppet log show as below:

Notice: Compiled catalog for hkw00156581 in environment dev in 0.72 seconds
Notice: /Stage[main]/box_sod/File[C:\box_sod]/ensure: created
Notice: /Stage[main]/box_sod/File[C:\box_software\]/ensur
e: defined content as '{md5}0083596aadeb7b798c78b8066c1a9483'
Notice: /Stage[main]/box_sod/Exec[Extract]: Triggered 'refre
sh' from 1 events

Notice: Finished catalog run in 11.11 seconds
edit retag flag offensive close merge delete