Ask Your Question
1

Somehow setup a relative path for Package and File source

asked 2014-08-08 21:55:21 -0600

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 {
    '192.168.120.0':    {$localserver = "\\aukpfp01\puppet$"}
    '192.168.202.0':    {$localserver = "\\auicdc02\puppet$"}
    '192.168.36.0':     {$localserver = "\\aubwwds01\puppet$"}
    '192.168.60.0':     {$localserver = "\\nzetfp01\puppet$"}
    '192.168.68.0':     {$localserver = "\\nzwgfp01\puppet$"}
    '192.168.70.0':     {$localserver = "\\auemfp01\puppet$"}
    '192.168.80.0':     {$localserver = "\\cnpdfp01\puppet$"}
    '192.168.81.0':     {$localserver = "\\cnfxfp01\puppet$"}
    '192.168.9.0':      {$localserver = "\\aukpfp01\puppet$"}
    '192.168.90.0':     {$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

Comments

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 -0600 )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 -0600 )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 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
2

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

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

Comments

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 { '192.168.120.0': {$localserver = "\\\\aukpfp01\\puppet\\"} '192.168.202.0': {$localserver = "\\\\auicdc02\\puppet\\"}

DJB gravatar imageDJB ( 2014-08-10 04:53:17 -0600 )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

Stats

Asked: 2014-08-08 21:55:21 -0600

Seen: 391 times

Last updated: Aug 10 '14