Search code examples
windowsfilepathpuppet

Spaces in file paths for puppet on Windows


I need to install some product using Puppet on Windows. I use exec recource

exec { 'install':
            command => 'C:\\windows\system32\cmd.exe /c "c:\\Program Files\\zabbix_agentd_64.exe --config c:\\Program Files\\zabbix_agentd.conf --install"',
            }

Syntax is ok, but I get

'c:/Program' is not recognized as an internal or external command

I tried also command => 'C:\\windows\system32\cmd.exe /c "c:\Program Files\zabbix_agentd_64.exe --config c:\Program Files\zabbix_agentd.conf --install"' and command => 'C:\\windows\system32\cmd.exe /c "c:\\Program/Files\\zabbix_agentd_64.exe --config c:\\Program/Files\\zabbix_agentd.conf --install"' but it says syntax error (rightly in fact). Any ideas?


Solution

  • Puppet (probably the Ruby underneath, actually) is splitting your command string into words without regard to the internal quotes. I don't think there is anything you can do to prevent that, but there is a related issue in Puppet's bug tracker. You could consider commenting on / voting up that issue. It should be possible to specify the command to the Exec in word-split form, as an array, which would provide a solution for your problem.

    I see two possible alternatives to get it working now:

    • Use the 8.3 name for the directory (see how to get DOS path instead of Windows path). This may be tricky, because I don't think the 8.3 path is uniquely determined by the file name alone -- it may be affected by the names of sibling files and directories.

    • Specify a PATH for the Exec by which the desired executable can be found, and run it by its simple name.