Problem setting fqdn on a node


#1

Hi chefs,

I’m having lots of problems when setting fqdn on ubuntu 10.04 nodes so chef
gets the fqdn right.

If I run ‘hostname fqdn’ hostname returns fqdn but hostname -f does not, and
the node gets registered with just the machine name.

The only way I found to make chef get the fqdn is adding an entry to
/etc/hosts with the ip address and the fqdn on the machine. I haven’t had
this problem on ubuntu 8.04 nodes.

I’d like to find another way to make this work than editing /etc/hosts
before chef register nodes.

Has anyone had this problems?

Greetings.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a


#2

How do you get your IP and domain? Are the machines assigned via dhcp? Do the ip addresses have reverse entries with the proper fqdn?

On 8/5/10 6:49 AM, “Jacobo García” jacobo.garcia@gmail.com wrote:

Hi chefs,

I’m having lots of problems when setting fqdn on ubuntu 10.04 nodes so chef gets the fqdn right.

If I run ‘hostname fqdn’ hostname returns fqdn but hostname -f does not, and the node gets registered with just the machine name.

The only way I found to make chef get the fqdn is adding an entry to /etc/hosts with the ip address and the fqdn on the machine. I haven’t had this problem on ubuntu 8.04 nodes.

I’d like to find another way to make this work than editing /etc/hosts before chef register nodes.

Has anyone had this problems?

Greetings.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a


#3

Machines are slicehost vms. How they get their fqdn goes like this:

  1. A new machine is added through slicehost panel, I give it a simple name
    like app01.
  2. The machine is based on a image that has a chef-bootstrap script on init.
    This script runs only on first boot, installs ruby, rubygems, chef, sets the
    fqdn and then registers the node on the opscode platform. This is the
    relevant part of the code

HOSTNAME=hostname
DOMAIN=foo.com

echo " - setting hostname to $HOSTNAME.$DOMAIN."
echo $HOSTNAME.$DOMAIN > /etc/hostname
sed -i s/$HOSTNAME/$HOSTNAME.$DOMAIN/ /etc/hosts
hostname $HOSTNAME.$DOMAIN

At this moment the machine does not have dns entries associated with it, but
if I this is a requisite I can work it out.
Also its ip address not assigned via dhcp (see above).

Thanks.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a

On Thu, Aug 5, 2010 at 7:10 PM, Leinartas, Michael <
MICHAEL.LEINARTAS@orbitz.com> wrote:

How do you get your IP and domain? Are the machines assigned via dhcp?
Do the ip addresses have reverse entries with the proper fqdn?

On 8/5/10 6:49 AM, “Jacobo García” jacobo.garcia@gmail.com wrote:

Hi chefs,

I’m having lots of problems when setting fqdn on ubuntu 10.04 nodes so chef
gets the fqdn right.

If I run ‘hostname fqdn’ hostname returns fqdn but hostname -f does not,
and the node gets registered with just the machine name.

The only way I found to make chef get the fqdn is adding an entry to
/etc/hosts with the ip address and the fqdn on the machine. I haven’t had
this problem on ubuntu 8.04 nodes.

I’d like to find another way to make this work than editing /etc/hosts
before chef register nodes.

Has anyone had this problems?

Greetings.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a


#4

Well not sure how helpful I’m going to be here as I’m not sure I quite understand your problem, but a few things:
Ohai (at least as of 0.5.6) merely runs a hostname -s for node[:hostname], hostname --fqdn for node[:fqdn] and for node[:domain] takes the fqdn value and chops the string to the first dot. So whatever changes you make, you can test them with those two commands to see if you’ve fixed anything.

In general (someone chime in if I’m incorrect):

short hostname goes in /etc/hostname
fqdn goes in /etc/hosts along with the short hostname with either localhost address or the primary IP of the server (I prefer primary IP, but example below is localhost)

127.0.0.1 server.domain.com server

Make sure you dont reverse those.

Now I’m not sure how slicehost bootstraps servers… Making the changes above should give you the correct responses from the hostname command, but only after a reboot. You may still need to experiment with the hostname command or changing /proc/sys/kernel/hostname and/or /proc/sys/kernel/domainname to do it without rebooting.

On 8/5/10 12:47 PM, “Jacobo García” jacobo.garcia@gmail.com wrote:

Machines are slicehost vms. How they get their fqdn goes like this:

  1. A new machine is added through slicehost panel, I give it a simple name like app01.
  2. The machine is based on a image that has a chef-bootstrap script on init. This script runs only on first boot, installs ruby, rubygems, chef, sets the fqdn and then registers the node on the opscode platform. This is the relevant part of the code

HOSTNAME=hostname
DOMAIN=foo.com http://foo.com

echo " - setting hostname to $HOSTNAME.$DOMAIN."
echo $HOSTNAME.$DOMAIN > /etc/hostname
sed -i s/$HOSTNAME/$HOSTNAME.$DOMAIN/ /etc/hosts
hostname $HOSTNAME.$DOMAIN

At this moment the machine does not have dns entries associated with it, but if I this is a requisite I can work it out.
Also its ip address not assigned via dhcp (see above).

Thanks.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a

On Thu, Aug 5, 2010 at 7:10 PM, Leinartas, Michael MICHAEL.LEINARTAS@orbitz.com wrote:
How do you get your IP and domain? Are the machines assigned via dhcp? Do the ip addresses have reverse entries with the proper fqdn?

On 8/5/10 6:49 AM, “Jacobo García” <jacobo.garcia@gmail.com http://jacobo.garcia@gmail.com > wrote:

Hi chefs,

I’m having lots of problems when setting fqdn on ubuntu 10.04 nodes so chef gets the fqdn right.

If I run ‘hostname fqdn’ hostname returns fqdn but hostname -f does not, and the node gets registered with just the machine name.

The only way I found to make chef get the fqdn is adding an entry to /etc/hosts with the ip address and the fqdn on the machine. I haven’t had this problem on ubuntu 8.04 nodes.

I’d like to find another way to make this work than editing /etc/hosts before chef register nodes.

Has anyone had this problems?

Greetings.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a


#5

Finally made it work with much more this same information. I received it on
ospcode support for their chef platform.

Here is the link, just for the record:

http://help.opscode.com/discussions/problems/74-unable-to-register-nodes-with-fqdn

I haven’t had any similar problem in aprox eight months of chef until last
week. It has taken a lot of time to fix it.

Thanks.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a

On Thu, Aug 5, 2010 at 11:33 PM, Leinartas, Michael <
MICHAEL.LEINARTAS@orbitz.com> wrote:

Well not sure how helpful I’m going to be here as I’m not sure I quite
understand your problem, but a few things:
Ohai (at least as of 0.5.6) merely runs a hostname -s for
node[:hostname], hostname --fqdn for node[:fqdn] and for node[:domain]
takes the fqdn value and chops the string to the first dot. So whatever
changes you make, you can test them with those two commands to see if you’ve
fixed anything.

In general (someone chime in if I’m incorrect):

short hostname goes in /etc/hostname
fqdn goes in /etc/hosts along with the short hostname with either localhost
address or the primary IP of the server (I prefer primary IP, but example
below is localhost)

127.0.0.1 server.domain.com server

Make sure you dont reverse those.

Now I’m not sure how slicehost bootstraps servers… Making the changes
above should give you the correct responses from the hostname command, but
only after a reboot. You may still need to experiment with the hostname
command or changing /proc/sys/kernel/hostname and/or
/proc/sys/kernel/domainname to do it without rebooting.

On 8/5/10 12:47 PM, “Jacobo García” jacobo.garcia@gmail.com wrote:

Machines are slicehost vms. How they get their fqdn goes like this:

  1. A new machine is added through slicehost panel, I give it a simple name
    like app01.
  2. The machine is based on a image that has a chef-bootstrap script on
    init. This script runs only on first boot, installs ruby, rubygems, chef,
    sets the fqdn and then registers the node on the opscode platform. This is
    the relevant part of the code

HOSTNAME=hostname
DOMAIN=foo.com http://foo.com

echo " - setting hostname to $HOSTNAME.$DOMAIN."
echo $HOSTNAME.$DOMAIN > /etc/hostname
sed -i s/$HOSTNAME/$HOSTNAME.$DOMAIN/ /etc/hosts
hostname $HOSTNAME.$DOMAIN

At this moment the machine does not have dns entries associated with it,
but if I this is a requisite I can work it out.
Also its ip address not assigned via dhcp (see above).

Thanks.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a

On Thu, Aug 5, 2010 at 7:10 PM, Leinartas, Michael <
MICHAEL.LEINARTAS@orbitz.com> wrote:

How do you get your IP and domain? Are the machines assigned via dhcp? Do
the ip addresses have reverse entries with the proper fqdn?

On 8/5/10 6:49 AM, “Jacobo García” <jacobo.garcia@gmail.com <
http://jacobo.garcia@gmail.com> > wrote:

Hi chefs,

I’m having lots of problems when setting fqdn on ubuntu 10.04 nodes so chef
gets the fqdn right.

If I run ‘hostname fqdn’ hostname returns fqdn but hostname -f does not,
and the node gets registered with just the machine name.

The only way I found to make chef get the fqdn is adding an entry to
/etc/hosts with the ip address and the fqdn on the machine. I haven’t had
this problem on ubuntu 8.04 nodes.

I’d like to find another way to make this work than editing /etc/hosts
before chef register nodes.

Has anyone had this problems?

Greetings.

Jacobo García López de Araujo
blog: http://robotplaysguitar.com
http://workingwithrails.com/person/13395-jacobo-garc-a