Ohai netwrk interface cache


#1

Hi

I have a problem with the network information being gathered by ohai. I am
trying to lookup the ip addrss by the network controller name (eth0 etc). When
I initially setup the server the network names were just the standard names.

But I have now changed the names of the network interfaces to make things
easier for me to track different networks and their connections.

However even though I have restarted the network interfaces and doing an
ifconfig brings up the correct names, when trying to get the ip address on the
new names, it fails. After some debugging it turns out that it is still
referencing the old network adapter names.

Is there a way to flush the ohai cache or tell it to get that information
again?

Thanks in advance.

Kind Regards
Thanks.


#2

On Monday, April 29, 2013 at 5:16 AM, hamza@khan-cheema.com wrote:

Hi

I have a problem with the network information being gathered by ohai. I am
trying to lookup the ip addrss by the network controller name (eth0 etc). When
I initially setup the server the network names were just the standard names.

But I have now changed the names of the network interfaces to make things
easier for me to track different networks and their connections.

Are you making these changes with chef and wish to see them reflected within the chef run?

However even though I have restarted the network interfaces and doing an
ifconfig brings up the correct names, when trying to get the ip address on the
new names, it fails. After some debugging it turns out that it is still
referencing the old network adapter names.

Is there a way to flush the ohai cache or tell it to get that information
again?

Ohai doesn’t have a cache. It’s information is fully refreshed on every chef run. If you need to refresh it within a chef run, see the ohai resource:

http://docs.opscode.com/chef/resources.html#ohai

If you need to debug what ohai is doing, you can run ohai -l debug on the command line.

Thanks in advance.

Kind Regards
Thanks.


Daniel DeLeo


#3

Hi

I am not making the changes within chef they have been done outside chef.
Thanks for the debug info. Although it has not helped me out.

If I explain the exact steps, I am taking, it might make things easier :slight_smile:

  1. The network names have been changed by editing the ifcfg-NAME files. A
    network name routes specific file has also been added for all new
    interfaces. The OS is Red Hat Enterprise 5

  2. An ifconfig lists the updated names and IP addresses.

  3. Running ohai on the server I can see the new network card name in the
    network json object. (network[:interfaces])

  4. In my chef recipe I am going through each node, except the logserver,
    pseudo code below:

servers = search (:node , “(NOT role:logserver)”)
servers.each do |server|

puts server[‘network’][‘interfaces’].keys

Code here that fails as it can’t find the network name in the above

hash.
end

  1. I am expecting to see printed out above the exception the network names
    which ifconfig and the ohai command line app are reporting. However I am
    seeing the original eth0, eth1 names.

If ohai does not cache any information, what else could be going on? I
have restarted chef-server, but that had no effect.

Thanks.

Kind Regards
Hamza Khan-Cheema
On 29 Apr 2013 18:04, “Daniel DeLeo” dan@kallistec.com wrote:

On Monday, April 29, 2013 at 5:16 AM, hamza@khan-cheema.com wrote:

Hi

I have a problem with the network information being gathered by ohai. I am
trying to lookup the ip addrss by the network controller name (eth0 etc).
When
I initially setup the server the network names were just the standard
names.

But I have now changed the names of the network interfaces to make things
easier for me to track different networks and their connections.

Are you making these changes with chef and wish to see them reflected
within the chef run?

However even though I have restarted the network interfaces and doing an
ifconfig brings up the correct names, when trying to get the ip address on
the
new names, it fails. After some debugging it turns out that it is still
referencing the old network adapter names.

Is there a way to flush the ohai cache or tell it to get that information
again?

Ohai doesn’t have a cache. It’s information is fully refreshed on every
chef run. If you need to refresh it within a chef run, see the ohai
resource:

http://docs.opscode.com/chef/resources.html#ohai

If you need to debug what ohai is doing, you can run ohai -l debug on
the command line.

Thanks in advance.

Kind Regards
Thanks.


Daniel DeLeo


#4

On Tuesday, April 30, 2013 at 5:02 AM, Hamza Khan-Cheema wrote:

Hi
I am not making the changes within chef they have been done outside chef. Thanks for the debug info. Although it has not helped me out.
If I explain the exact steps, I am taking, it might make things easier :slight_smile:

  1. The network names have been changed by editing the ifcfg-NAME files. A network name routes specific file has also been added for all new interfaces. The OS is Red Hat Enterprise 5
  2. An ifconfig lists the updated names and IP addresses.
  3. Running ohai on the server I can see the new network card name in the network json object. (network[:interfaces])
  4. In my chef recipe I am going through each node, except the logserver, pseudo code below:
    servers = search (:node , “(NOT role:logserver)”)
    servers.each do |server|
    puts server[‘network’][‘interfaces’].keys

Code here that fails as it can’t find the network name in the above hash.

end
5) I am expecting to see printed out above the exception the network names which ifconfig and the ohai command line app are reporting. However I am seeing the original eth0, eth1 names.
If ohai does not cache any information, what else could be going on? I have restarted chef-server, but that had no effect.

Short answer: re-run chef-client on each host after you update the network config.

The data you see in search is saved by individual chef clients at the conclusion of each chef run. Running chef-client on a regular basis will keep this info more up-to-date, but in general chef doesn’t have any mechanism for knowing when a change made outside of chef requires an update to the node data.

You can see what’s currently on your chef server with knife node show and knife search (check the -m, -l, and -a options, as these normally only show summaries to avoid deluging you with data).


Daniel DeLeo


#5

Thanks for the answer. Running chef-client has fixed the problem :slight_smile:

So it does appear that some ohai data is cached after all.

Kind Regards
Hamza Khan-Cheema

On 1 May 2013, at 06:36, Daniel DeLeo wrote:

On Tuesday, April 30, 2013 at 5:02 AM, Hamza Khan-Cheema wrote:

Hi

I am not making the changes within chef they have been done outside chef. Thanks for the debug info. Although it has not helped me out.

If I explain the exact steps, I am taking, it might make things easier :slight_smile:

  1. The network names have been changed by editing the ifcfg-NAME files. A network name routes specific file has also been added for all new interfaces. The OS is Red Hat Enterprise 5

  2. An ifconfig lists the updated names and IP addresses.

  3. Running ohai on the server I can see the new network card name in the network json object. (network[:interfaces])

  4. In my chef recipe I am going through each node, except the logserver, pseudo code below:

servers = search (:node , “(NOT role:logserver)”)
servers.each do |server|

puts server[‘network’][‘interfaces’].keys

Code here that fails as it can’t find the network name in the above hash.

end

  1. I am expecting to see printed out above the exception the network names which ifconfig and the ohai command line app are reporting. However I am seeing the original eth0, eth1 names.

If ohai does not cache any information, what else could be going on? I have restarted chef-server, but that had no effect.

Short answer: re-run chef-client on each host after you update the network config.

The data you see in search is saved by individual chef clients at the conclusion of each chef run. Running chef-client on a regular basis will keep this info more up-to-date, but in general chef doesn’t have any mechanism for knowing when a change made outside of chef requires an update to the node data.

You can see what’s currently on your chef server with knife node show and knife search (check the -m, -l, and -a options, as these normally only show summaries to avoid deluging you with data).


Daniel DeLeo