Building directory path with directory resource


#1

All -

I am trying to build a directory path by using attributes but it isn’t working the way I expected.

Here are the relevant attributes:

default[‘jboss’][‘jboss_home’] = "/as/app/jboss"
default[‘jboss’][‘version’] = "7.1.3"
default[‘jboss’][‘jboss_user’] = “vagrant”

And here is my directory resource code:

directory “#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘jboss_version’]}” do

owner node[‘jboss’][‘jboss_user’]

recursive true

action :create
end

What I want is to have this path created:

/as/app/jboss/7.1.3

What I am getting is

/as/app/jboss

How do I append multiple attributes together in the directory resource?

Thanks,
Mark


#2

Here’s the issue:

Your line:

directory “#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘jboss_version’]}” do

The line you probably want:

directory “#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘version’]}” do

-M

On Wed, Jun 26, 2013 at 11:49 AM, Mark H. Nichols chef@zanshin.net wrote:

All -

I am trying to build a directory path by using attributes but it isn’t
working the way I expected.

Here are the relevant attributes:

default[‘jboss’][‘jboss_home’] = "/as/app/jboss"
default[‘jboss’][‘version’] = "7.1.3"
default[‘jboss’][‘jboss_user’] = “vagrant”

And here is my directory resource code:

directory "#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘jboss_version’]}"
do
owner node[‘jboss’][‘jboss_user’]
recursive true
action :create
end

What I want is to have this path created:

/as/app/jboss/7.1.3

What I am getting is

/as/app/jboss

How do I append multiple attributes together in the directory resource?

Thanks,
Mark


#3

Nice catch!
On Jun 26, 2013 8:55 AM, “Mike” miketheman@gmail.com wrote:

Here’s the issue:

Your line:

directory
"#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘jboss_version’]}" do

The line you probably want:

directory “#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘version’]}” do

-M

On Wed, Jun 26, 2013 at 11:49 AM, Mark H. Nichols chef@zanshin.net
wrote:

All -

I am trying to build a directory path by using attributes but it isn’t
working the way I expected.

Here are the relevant attributes:

default[‘jboss’][‘jboss_home’] = "/as/app/jboss"
default[‘jboss’][‘version’] = "7.1.3"
default[‘jboss’][‘jboss_user’] = “vagrant”

And here is my directory resource code:

directory
"#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘jboss_version’]}"
do
owner node[‘jboss’][‘jboss_user’]
recursive true
action :create
end

What I want is to have this path created:

/as/app/jboss/7.1.3

What I am getting is

/as/app/jboss

How do I append multiple attributes together in the directory resource?

Thanks,
Mark


#4

On Jun 26, 2013, at 10:55 AM, Mike miketheman@gmail.com wrote:

Here’s the issue:

Your line:

directory “#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘jboss_version’]}” do

The line you probably want:

directory “#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘version’]}” do

D’oh. hangs head in shame I’ve looked at this for a day now and never once saw that I had the wrong attribute name. Thanks for the catch.

Mark


#5

With dynamic languages these are very common.
Use pry and drop a binding.pry inside the recipe , this will help you
inspect individual attribute values and other stuff. You can do this with
chef shell -z also :slight_smile:
On Jun 26, 2013 9:26 AM, “Mark H. Nichols” chef@zanshin.net wrote:

On Jun 26, 2013, at 10:55 AM, Mike miketheman@gmail.com wrote:

Here’s the issue:

Your line:

directory
"#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘jboss_version’]}" do

The line you probably want:

directory “#{node[‘jboss’][‘jboss_home’]}/#{node[‘jboss’][‘version’]}” do

D’oh. hangs head in shame I’ve looked at this for a day now and never
once saw that I had the wrong attribute name. Thanks for the catch.

Mark