pranad
September 2, 2018, 10:33am
1
i am trying write code to copy krb5.conf to the server only if the server have gateway (172.01.112.1) but here it seem node['default_gateway'] is not working.
cookbook_file '/etc/krb5.conf' do
only_if { node['default_gateway'] == '172.01.112.1' }
source 'krb5.conf'
backup 5
end
Please help me with it
thanks in advance
Larryc
September 2, 2018, 3:18pm
2
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
vs
knife node show servername -a network.default_gateway
Check out the examples under SHOW in the knife node docs
https://docs.chef.io/knife_node.html
Larryc
September 2, 2018, 5:21pm
4
No problem, if you are all good I think you can mark this solved.
pranad
September 4, 2018, 2:20am
5
Any idea , similarly how to get netmask value.
Larryc
September 4, 2018, 12:11pm
6
it appears to be buried a bit
['network']['interfaces']['$interfacename']['addresses']['ipaddress']['netmask']
So it would need something like
['network']['interfaces']['eth0']['addresses']['192.168.1.10']['netmask']
Im not sure if this would work or not
['network']['interfaces']['node['network']['default_interface']']['addresses']['node['ipaddress']']['netmask']