Need help using node ['default_gateway']

i am trying write code to copy krb5.conf to the server only if the server have gateway ( but here it seem node['default_gateway'] is not working.

cookbook_file '/etc/krb5.conf' do
only_if { node['default_gateway'] == '' }
source 'krb5.conf'
backup 5

Please help me with it
thanks in advance

That ohai attribute is nested under network, you need to use node['network']['default_gateway']

for example from your chef repo directory run

knife node show servername -a default_gateway


knife node show servername -a network.default_gateway

Check out the examples under SHOW in the knife node docs

Thx! It worked

Your like god :wink:

No problem, if you are all good I think you can mark this solved.

Any idea , similarly how to get netmask value.

it appears to be buried a bit

So it would need something like


Im not sure if this would work or not