Div
Div

Reputation: 19

chef attributes value not getting parsed in another attribute

I am setting attributes in default.rb as

default[:my_app] = {
  :vol => "data02",
  :commitlog => "/foo/bar/node[:vol]/commitlog",
}

But :vol value is not getting parsed in commitlog attribute and I am getting following error.

mError executing action `create` on resource 'directory[/foo/bar/node[:vol]/comitlog]'[0m

Upvotes: 0

Views: 177

Answers (2)

Div
Div

Reputation: 19

Even after I am using the interpolation syntax, and when I am using node[:my_app][:commitlog] in recipe it shows /foo/bar//commitlog

Upvotes: 0

Martin
Martin

Reputation: 2825

You're missing the String interpolation syntax, e.g. y = "The value of X is #{X}." You probably want:

default[:my_app] = {
  :vol => "data02",
  :commitlog => "/foo/bar/#{node[:vol]}/commitlog",
}

Also, keep in mind that if you make one attribute depend on the value of another, you might override node[:my_app][:vol] later and expect the value of node[:my_app][:commitlog] to change with it, and it may not. The attributes will be parsed together, potentially before your override affects the first one.

Upvotes: 2

Related Questions