5

I have been experimenting with open source chef server. I configured a node on my server which had ip address 10.114.7.41. Now when I restarted the node machine and now the ip address of the machine has changed to 10.114.7.45. But the chef server still has the ip address of this node as the previous one which can be checked by:

knife search 'node:name'

How can I rectify this from my workstation/chef-server? I am not able to 'knife ssh' the node machine. Thanks!

Amar
  • 2,171
  • 1
  • 13
  • 16

2 Answers2

8

If you can access the node and re-run chef-client, it should pick up the new IP address and change it for you. Ohai runs at the beginning of each chef-client run and collects this data and updates the chef server.

Michael Goetz
  • 410
  • 2
  • 5
  • I know but this requires chef-client to be run manually or by ssh on the new ip address. But my questions is how can it be managed by workstation or directly changing it from chef server. – Amar Mar 03 '14 at 21:41
  • The chef-client has to run in order to change automatic attributes set by Ohai. You can't edit that value manually. – Michael Goetz Mar 04 '14 at 22:26
  • Does this mean in a DHCP environment chef is not a good choice for provisioning? – Amar Mar 05 '14 at 08:35
  • No, chef is fine for provisioning in a DHCP environment. Are you re-assigning IPs routinely? Typically, you have your IP address assigned before you can even bootstrap, so I'm not sure what configuration you are using. If your IP address is changing after the initial provisioning with Chef, you will have to re-run chef-client to update the node object with the new information. – Michael Goetz Mar 05 '14 at 21:44
  • Apart from running the chef client as cron job, can I rectify the issue from workstation? – Amar Mar 05 '14 at 22:00
  • 3
    You could execute a `knife node edit nodename -a` which would let you edit all attributes on the node object by hand. I don't really recommend this though as it's always easy to accidentally make typos. – Michael Goetz Mar 06 '14 at 22:26
0

So the best solution is -m with the knife invocation?

knife ssh -m host.dhcp.net -- chef-client 

.. always seemed a little gauche.

user2066657
  • 444
  • 1
  • 4
  • 23