Create recursive directories with hostname in path

Hello

I need to create directories that has hostname in the path, I tried a few different ways to resolve node['hostname'] but no luck

hostname variable isn't expanded when creating directory

I get directories created literally like node['hostname'] , #{ node['hostname']}, "#{ node['hostname']}"

I have tried different ways like

#{hostname}, node['hostname'] , #{ node['hostname']}, "#{ node['hostname']}" inside gemfire_directories = %w( )

My code :

hostname = node['hostname']

gemfire_directories = %w(
/opt/pivotal/gemfire
/opt/pivotal/gemfire/#{hostname}
/var/log/pivotal/gemfire/#{hostname}/stats
/var/log/pivotal/gemfire/#{hostname}/logs
/opt/pivotal/gemfire/staging/system
/opt/pivotal/gemfire/staging/application
/opt/pivotal/gemfire/scripts
/opt/pivotal/gemfire/scripts/env
/opt/pivotal/gemfire/scripts/sh
/opt/pivotal/gemfire/scripts/py
/opt/pivotal/gemfire/security
/opt/pivotal/gemfire/security/certs
/opt/pivotal/gemfire/config
/sys_data/pivotal/gemfire/backup
/sys_api/consumers
)

gemfire_directories.each do |gemfire_directory|
  directory gemfire_directory do
    group node['gemfire']['group']
    owner node['gemfire']['owner']
    mode node['mode']
    recursive true
    action :create
  end
end

Thanks

Murry

i started with following this example from https://docs.chef.io/resources/directory/,
my only difference is I need to have hostname resolved

%w[ /foo /foo/bar /foo/bar/baz ].each do |path|
  directory path do
    owner 'root'
    group 'root'
    mode '0755'
  end
end

i figured it out. it's upper case W in, %W

Thanks