Search code examples
windowspuppet

Windows puppet exec command file path


I wonder if it's possible in puppet (windows agent) for a variable to hold the value of a file name, then add this variable value to an exec windows cmd.exe command? i.e. I'm trying to copy a file from a shared drive to c:\temp like this:

$setup_msi = "myprogram.msi"

exec { 'copy_MSI_c:\temp': 
command => 'C:\\windows\system32\cmd.exe /c "copy i:\\data\\${setup_msi}" c:\\temp'
}

But when the windows puppet agent runs, puppet parses the $setup_msi variable name itself and not the value that said variable contains. I was hoping it would parse it like this: C:\windows\system32\cmd.exe /c "copy i:\data\myprogram.msi c:\temp"

Any help would be greattly appreciated.

Thanks.

Fr3edom21.


Solution

  • After spending too much time on getting this to work, I found a workaround like this:

    $setup_msi = "i:\\data\\myprogram.msi"
    
        exec { 'copy_MSI_c:\temp':
            command => "C:\\windows\\system32\\cmd.exe /c copy ${setup_msi} c:\\temp",
        }
    

    Fr3edom21.