First of all, I'm new to programming, also new to chef cookbooks. But I'm playing around and got stuck trying to figure out how get the cookbook block that got changed.
For example:
cookbook_file '/etc/wil.conf' do
source 'wil.conf'
owner 'root'
group 'root'
mode '0644'
action :create
end
cookbook_file '/etc/wel.conf' do
source 'wel.conf'
owner 'root'
group 'root'
mode '0644'
action :create
end
ruby_block 'sendpost' do
block do
`curl -s -o /dev/null -w "%{http_code}" -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"appId":"APP","category":"APPLICATION","waterMark":null,"timestamp":"{EVENT.DATE}","status":"{Active}","resource":"#{changed}","alertTime":"{EVENT.AGE}","gateway":"#{ENV['HOSTNAME']}"}' http://server:port/context`
end
action :nothing
subscribes :run, 'cookbook_file[/etc/wil.conf]', :immediately
subscribes :run, 'cookbook_file[/etc/wel.conf]', :immediately
end
I'm versioning some config files, and wrote a ruby_block to send a post request, my question is, I'm trying to know which one of the two resources got changed, either:
wil.conf or
wel.conf
so in my curl, I would send along with my request the resource cookbook_file name block that was changed ("resource":"{ ??? file that was changed ??? }")
I'm getting some host variables with #{ENV['HOSTNAME']}. How to get the block name that got change in runtime?
Thanks in advance.