How to get a linux command output to chef attribute on chef13 client


#1

I try with the
ruby_block 'Lookup IPs' do
block do
Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
command = 'bash /tmp/ListELBInstanceIPs.sh'
command_out = shell_out(command)
node.default['my_ips'] = command_out.stdout.strip
end
action :create
end
This rubyblock is not working with the chef13 client, Can any one has any idea on this issue please keep me posted.


#2

Do you have an error ?

From what I see, I would use an include instead of using send() which is probably too late as your ruby_block is already created.


#3

I am trying to get the IPS from ELB(AWS load balancer ) it's not reading that values


#4

Does your bash script works if you run it from a terminal ?


#5

Yes, it working and I am getting IPS.


#6
ruby_block 'Lookup IPs' do
  block do
    Chef::Resource::RubyBlock.send(:include, Chef::Mixin::ShellOut)
    command = 'bash /tmp/ListELBInstanceIPs.sh'
    command_out = shell_out(command)
    Chef::Log.warn(command_out.stdout * 20)
    node.default['my_ips'] = command_out.stdout.strip
  end
  action :create
end

Run this and let me know what do you have in your chef client logs.