How can I set the hostname of a node via a recipe?


#1

Is it possible to set the hostname via a recipe? If so does a cookbook exist
already, I couldnt find one before.

Cheers
Jono


#2

Some combination of the dynect (opscode) reboot (dreamcat4) and a couple of
execute resources would probably do the trick.

Regards,

AJ

On 17 November 2010 19:46, jono@spiralarm.com wrote:

Is it possible to set the hostname via a recipe? If so does a cookbook
exist
already, I couldnt find one before.

Cheers
Jono


#3

Given that Chef uses the host name as its primary identifier you better
be careful. You should set the name during build or if you must then
use a different primary key

|||-N, --node-name NODE_NAME The node name||for||this||client|

http://wiki.opscode.com/display/chef/Chef+Client

or node_name in the client.rb

http://wiki.opscode.com/display/chef/Chef+Configuration+Settings

I have always thought the mac address would make a much better uniq id,
and then use node[:fqdn] for gui / knife output.

Joshua

AJ Christensen wrote:

Some combination of the dynect (opscode) reboot (dreamcat4) and a
couple of execute resources would probably do the trick.

Regards,

AJ

On 17 November 2010 19:46, <jono@spiralarm.com
mailto:jono@spiralarm.com> wrote:

Is it possible to set the hostname via a recipe? If so does a
cookbook exist
already, I couldnt find one before.

Cheers
Jono

#4

On Tue, Nov 16, 2010 at 11:24 PM, Joshua Miller jassinpain@gmail.comwrote:

Given that Chef uses the host name as its primary identifier you better be
careful. You should set the name during build or if you must then use a
different primary key

   -N, --node-name NODE_NAME        The node name for this client

http://wiki.opscode.com/display/chef/Chef+Client

or node_name in the client.rb

http://wiki.opscode.com/display/chef/Chef+Configuration+Settings

I have always thought the mac address would make a much better uniq id, and
then use node[:fqdn] for gui / knife output.

I think the best ID to use really depends on your infrastructure. Using the
hostname works really well when you have a small-ish number of semantically
(or whimsically) named boxes (like app1.example.com or centaur.example.com)
where everyone knows the boxes by name. If you’re on EC2, then instance ids
are a good choice (same with other cloud providers and their unique ids). In
a large setup with tons of physical boxes that PXE boot, you might do
something different or roll your own guid service (and you couldn’t use MAC
addresses either).

So it’s really all about the tradeoffs for your environment.

Joshua

On 17 November 2010 19:46, jono@spiralarm.com wrote:

Is it possible to set the hostname via a recipe? If so does a cookbook
exist
already, I couldnt find one before.

Cheers
Jono

As mentioned earlier, changing the hostname is as simple as managing
whatever files your distro/OS uses to set the hostname, but if you’re
planning to do this, set the node name in the client.rb when you first
register the node.

Dan DeLeo


#5

I have a cookbook to set /etc/hosts, not sure if it’s been pulled on the
main cookbooks repo

https://github.com/peerpong/cookbooks/tree/hosts/hosts/

-> works with rackspace or no cloud provider. Feel free to update or modify

–Gilles

On Wed, Nov 17, 2010 at 9:04 AM, Daniel DeLeo dan@kallistec.com wrote:

On Tue, Nov 16, 2010 at 11:24 PM, Joshua Miller jassinpain@gmail.comwrote:

Given that Chef uses the host name as its primary identifier you better
be careful. You should set the name during build or if you must then use a
different primary key

   -N, --node-name NODE_NAME        The node name for this client

http://wiki.opscode.com/display/chef/Chef+Client

or node_name in the client.rb

http://wiki.opscode.com/display/chef/Chef+Configuration+Settings

I have always thought the mac address would make a much better uniq id,
and then use node[:fqdn] for gui / knife output.

I think the best ID to use really depends on your infrastructure. Using the
hostname works really well when you have a small-ish number of semantically
(or whimsically) named boxes (like app1.example.com or centaur.example.com)
where everyone knows the boxes by name. If you’re on EC2, then instance ids
are a good choice (same with other cloud providers and their unique ids). In
a large setup with tons of physical boxes that PXE boot, you might do
something different or roll your own guid service (and you couldn’t use MAC
addresses either).

So it’s really all about the tradeoffs for your environment.

Joshua

On 17 November 2010 19:46, jono@spiralarm.com wrote:

Is it possible to set the hostname via a recipe? If so does a cookbook
exist
already, I couldnt find one before.

Cheers
Jono

As mentioned earlier, changing the hostname is as simple as managing
whatever files your distro/OS uses to set the hostname, but if you’re
planning to do this, set the node name in the client.rb when you first
register the node.

Dan DeLeo


#6

Cheers all I’ll have a look at the suggestions in the next few days.

Jono

On 18 November 2010 06:44, Gilles Devaux gilles.devaux@gmail.com wrote:

I have a cookbook to set /etc/hosts, not sure if it’s been pulled on the
main cookbooks repo

https://github.com/peerpong/cookbooks/tree/hosts/hosts/

-> works with rackspace or no cloud provider. Feel free to update or modify

–Gilles

On Wed, Nov 17, 2010 at 9:04 AM, Daniel DeLeo dan@kallistec.com wrote:

On Tue, Nov 16, 2010 at 11:24 PM, Joshua Miller jassinpain@gmail.comwrote:

Given that Chef uses the host name as its primary identifier you better
be careful. You should set the name during build or if you must then use a
different primary key

   -N, --node-name NODE_NAME        The node name for this client

http://wiki.opscode.com/display/chef/Chef+Client

or node_name in the client.rb

http://wiki.opscode.com/display/chef/Chef+Configuration+Settings

I have always thought the mac address would make a much better uniq id,
and then use node[:fqdn] for gui / knife output.

I think the best ID to use really depends on your infrastructure. Using
the hostname works really well when you have a small-ish number of
semantically (or whimsically) named boxes (like app1.example.com or
centaur.example.com) where everyone knows the boxes by name. If you’re on
EC2, then instance ids are a good choice (same with other cloud providers
and their unique ids). In a large setup with tons of physical boxes that PXE
boot, you might do something different or roll your own guid service (and
you couldn’t use MAC addresses either).

So it’s really all about the tradeoffs for your environment.

Joshua

On 17 November 2010 19:46, jono@spiralarm.com wrote:

Is it possible to set the hostname via a recipe? If so does a cookbook
exist
already, I couldnt find one before.

Cheers
Jono

As mentioned earlier, changing the hostname is as simple as managing
whatever files your distro/OS uses to set the hostname, but if you’re
planning to do this, set the node name in the client.rb when you first
register the node.

Dan DeLeo