Chef attributes value reuse

159 Views Asked by At

Versions :

  • Server 12
  • chef client 12.13.37

I have an attribute file with a lot of url references but all to the same server. I'd like to reference a base url to build up the full path. Then if the source server changes I just change the top attribute.

original

default['cookbook'][1.1]['zipurl']  = 'http://server/something/version/SERVER.zip'

planned

default['cookbook'][1.1]['packagesurl'] = 'http://server/'

default['cookbook'][1.1]['zipurl']  = '"#{default['cookbook'][version]['packagesurl']}"something/version/SERVER.zip'

It compiles and uploads ok but the chef run returns the following :

"#default{['cookbook'][version]['packagesurl']}something/version/server.zip" is not a valid `source` parameter for remote_file. `source` must be an absolute URI or an array of URIs.

probably some basic syntax wrong ...

I looked in the attributes of some of the supermarket public cookbooks and they call use the full paths so this might not be possible.

1

There are 1 best solutions below

1
On

You need to use double quotes (") for #{} interpolation to work in Ruby. Also check out poise-derived for another option that might fix a few footguns before you find them yourself.