Ask Your Question

Somehow setup a relative path for Package and File source

asked 2014-08-08 21:55:21 -0500

DJB gravatar image

Hi Guys,

I maintain a geographically distributed windows environment and have a requirement for nodes to download files and run installers from sources local to there $networklocalarea_connection.

I have setup a common variable for different networks.

case $network_local_area_connection {
    '':    {$localserver = "\\aukpfp01\puppet$"}
    '':    {$localserver = "\\auicdc02\puppet$"}
    '':     {$localserver = "\\aubwwds01\puppet$"}
    '':     {$localserver = "\\nzetfp01\puppet$"}
    '':     {$localserver = "\\nzwgfp01\puppet$"}
    '':     {$localserver = "\\auemfp01\puppet$"}
    '':     {$localserver = "\\cnpdfp01\puppet$"}
    '':     {$localserver = "\\cnfxfp01\puppet$"}
    '':      {$localserver = "\\aukpfp01\puppet$"}
    '':     {$localserver = "\\aukdfp01\puppet$"}

I have also setup a large number of packages should be installed. One example below

package { VeryLargeApp:
        ensure          => installed,
        source          => '**$localserver**\software\Apple\VeryLargeApp.exe',
        install_options => ['/qn'],

When ever a PuppetRun occurs the output for packages or files utilizing a $variable in the Source I am returned with this output. "Cannot use relative URLs"

Any suggestions for how this can be achieved are welcomed.

edit retag flag offensive close merge delete


in your case statement try wrapping the values for `$localserver` in single quotes. From the looks of it your essentially saying `&localserver = "\aukpfp01puppet$"`. I amy be wrong though.

ptierno gravatar imageptierno ( 2014-08-09 16:13:28 -0500 )edit

Thanks for your suggestion. I unfortunately received the same error. I have tried a mixture of combinations including '$' "$" '${}' "${}" Which all spit out the same error. I than tried to be creative and have Puppet create a Windows Variable %localserver% and than use in the source path instead. :(

DJB gravatar imageDJB ( 2014-08-10 01:16:03 -0500 )edit

If Ptierno or anyone reading this has any suggestions for I how I can achieve a variable source using any method, that would be awesome.

DJB gravatar imageDJB ( 2014-08-10 01:17:22 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2014-08-10 03:11:31 -0500

Gary Steven gravatar image

Try this, you need to use double quotes in a string with variables in order to properly expand the variable and since the path is in the string as well you will want to escape your backslashes with an extra backslash.

package { 'VeryLargeApp':
  ensure          => latest,
  source          => "${localserver}\\software\\Apple\\VeryLargeApp.exe",
  install_options => ['/qn']
edit flag offensive delete link more


I literally after hours of trial and error came back here to post my own answer for everyone. But Gary beat me to it. Thank you Gary, I can confirm this works perfectly. Just noting for anyone else with this requirement my case statement looks like this case $network_local_area_connection { '': {$localserver = "\\\\aukpfp01\\puppet\\"} '': {$localserver = "\\\\auicdc02\\puppet\\"}

DJB gravatar imageDJB ( 2014-08-10 04:53:17 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-08-08 21:55:21 -0500

Seen: 363 times

Last updated: Aug 10 '14