How to change ip address of node after added to chef-server

Maybe instead of relying on node[:ipaddress] you can rely on
node[:network][:interfaces][:eth0][:addresses] hash. It has all the network
info you may need. To get the IPv4 address you need to check for value of
"family":

node[:network][:interfaces][:eth0][:addresses].each do |addr|
if addr[:family] == "inet"
return addr # not sure if this var contains actual value..
end
end

Here's relevant section from ohai output:

"network": {
"interfaces": {
"eth0": {
"type": "eth",
"number": "0",
"mtu": "1500",
"flags": [
"BROADCAST",
"MULTICAST",
"UP",
"LOWER_UP"
],
"encapsulation": "Ethernet",
"addresses": {
"06:84:8E:00:1D:A6": {
"family": "lladdr"
},
"10.190.34.22": {
"family": "inet",
"prefixlen": "23",
"netmask": "255.255.254.0",
"broadcast": "10.190.35.255",
"scope": "Global"
},
"fe80::484:8eff:fe00:1da6": {
"family": "inet6",
"prefixlen": "64",
"scope": "Link"
}

On Thu, Jul 10, 2014 at 8:33 PM, Matt Ray matt@getchef.com wrote:

Not to say you "can't", you just need to determine why ohai is setting
it the way it is and possibly replace the offending behavior. You
could add a new ohai plugin to modify the behavior, or potentially
submit a patch if it's a bug in ohai.

About Ohai

Thanks,
Matt Ray
Director of Partner Integration :: Chef
512.731.2218 :: matt@getchef.com
mattray :: GitHub :: IRC :: Twitter

On Thu, Jul 10, 2014 at 12:00 PM, Fitzwater, Brian K (CTR)
brian.k.fitzwater@uscis.dhs.gov wrote:

The ipaddress is an automatic attribute detected by ohai. It defaults to
the default route. All attributes collected by Ohai are unmodifiable by
the
chef-client.

So, the short answer is: you can’t (unless you change the default
route…but
that will probably break something)

From: idzzy [mailto:idezebi@gmail.com]
Sent: Thursday, July 10, 2014 10:31 AM
To: chef@lists.opscode.com
Subject: [chef] how to change ip address of node after added to
chef-server.

Hello,

Let me ask about how to change ip address of node after added to
chef-server.

target sever has some ip address like this.

eth0 : 192.168.10.1

eth1: 192.168.20.1

eth2: 192.168.30.1

I run bootstrap from chef workstation to the target server. workstation
has
192.168.10.100.


knife bootstrap 192.168.10.1 -N node-4 -E poc -x root -d centos6


and then completed to install chef-client, registered to chef-server.

chef-serrver has 192.168.10.200

So all (workstation / chef-server / target-server) is in 192.168.10.x

But the ip address registered to chef-server is 192.168.20.1. Why?

How can I change the ip address to 192.168.10.1?


knife node show node-4

Node Name: node-4

Environment: poc

FQDN: node-4

IP: 192.168.20.1

Run List:

Roles:

Recipes:

Platform: centos 6.5

Tags:


I already use edit command, but there is not ip address.

and also “-a” option, but I’m not sure which part should I modify.


knife node edit node-4

{

"name": "node-4",

"chef_environment": "poc",

"normal": {

"tags": [



]

},

"run_list": [

]

}


Thank you.

idzzy

--
Best regards, Dmitriy V.