0

I keep getting the error 'Could not find command 'C:\puppetfolder\unzip.exe' or 'Could not find command 'C:\puppetfolder\ 7-Zip.exe' whichever one I try… basically I’m trying to unzip a zipped file (server.zip) into the directory C:\puppetfolder. Puppet is able to dowmload 7z1507.exe and unzip.exe in the C:\puppetfolder\ directory so the executales are their. But should I be using extract, unpack, unzip or 7zip in the command attribute to get this server.zip file to unzip into the same directory? Or is my argument wrong for this use case?

-> file { 'C:\puppetfolder\7z1507.exe':

ensure   => 'present',
provider => 'windows',
mode     => '0775',
owner    => 'Administrator',
group    => 'Administrator',

}

-> file { 'C:\puppetfolder\unzip.exe':

ensure  => 'present',
mode    => '0775',
owner   => 'Administrator',
group   => 'Administrator',

}

->

file { 'C:\puppetfolder\server.zip':

ensure   => 'file',
source   => 'puppet:///modules/downloadscript/server.zip',
checksum => 'mtime',
mode     => '0775',
owner    => 'Administrator',
group    => 'Administrator',

}

-> exec {'unzip_c:\puppetfolder\server.zip':

 path         => 'c:\\puppetfolder\\unzip.exe',
command      => "C:\\puppetfolder\\unzip.exe /c C:\\puppetfolder\\server.zip C:\\puppetfolder -y",
provider     =>  'windows',

}

-> exec { 'install_c:\puppetfolder\downloadtest.ps1':

command     => 'C:\\puppetfolder\\downloadtest.bat',
logoutput   => 'true',
provider    => 'windows',

} }

1 Answers1

0

There is a module on the forge reidmv-unzip that will provide an unzip type.

puppet module install reidmv-unzip

Then you can define the source and destination of the zip contents. The source must be a local file on the Windows system.

With that type, your manifest would be rewritten to the following:

file { 'C:/puppetfolder/server.zip':
  ensure   => 'file',
  source   => 'puppet:///modules/downloadscript/server.zip',
  checksum => 'mtime',
  mode     => '0775',
  owner    => 'Administrator',
  group    => 'Administrator',
}
->
unzip { 'server-file':                            
  source  => 'C:/puppetfolder/server.zip',               
  creates => 'C:/puppetfolder/downloadtest.bat',                                                                            
}
->
exec { 'install_c:/puppetfolder/downloadtest.ps1':
  command     => 'C:/puppetfolder/downloadtest.bat',
  logoutput   => 'true',
  provider    => 'windows',
}
saq0
  • 1