I have two attributes like these:
default['cookbook']['array1'] = [ "a", "b", "c", "d" ]
default['cookbook']['array2'] = [ "x", "y", "z", "w" ]
I need to pass these attributes as variables to a template like this:
template "/tmp/some.sh" do
source "some.sh.erb"
owner 'root'
group 'root'
mode "0755"
variables(
:bash_array1 => node['cookbook']['array1'],
:bash_array2 => node['cookbook']['array2']
)
end
In my bash script i need to have two arrays which will have each, the value of the two array above, like this
#!/bin/bash
inputs1=( "a" "b" "c" "d" )
inputs2=( "x" "y" "z" "w" )
What's the simpliest way to do it?
Thank you,
Gabriel
EDIT: The sh.erb file with what I've tried until now looks like this:
####### the original sh file #########
#inputs1=( "a" "b" "c" "d" ) #this is the original sh file
#inputs2=( ""x" "y" "z" "w" )
####### end of the original sh file #########
What I've tried:
inputs1=<%= @bash_array1 %>
inputs2=<%= @bash_array2 %>
and the result:
inputs1=[ "a", "b", "c", "d" ] #which cannot be used
inputs2=[ "x", "y", "z", "w" ] #which cannot be used
The end result in my sh should be
inputs1=( "a" "b" "c" "d" )
inputs2=( "x" "y" "z" "w" )