Newly built machine registers as localhost under Hosts report

Hi there,

I'm performing some test builds with foreman 1.4.1. The server builds
fine, but when I look under Hosts -> All Hosts my newly built machine comes
up as "localhost.internal.mydomain.com"

I'm using a fairly standard RHEL kickstart template and have this in the
post section:

Setup puppet to run on system reboot

/sbin/chkconfig --level 345 puppet on
/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags
no_such_tag <%= @host.puppetmaster.blank? ? '' : "–server
#{@host.puppetmaster}" %> --no-daemonize

I've tried adding the following before the agent is called to make sure the
hostname is set when puppet is called but that didn't help:

hostname=<%= @host %>

Any idea what I might have missed?

My /etc/hosts after the server builds looks like this:

127.0.0.1 test1.internal.mydomain.com test1
localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6

And after the build, facter seems to report the correct name:

[root@test1 etc]# facter| grep host
hostname => test1

I have "ignore_puppet_facts_for_provisioning" set to false - do I need to
change that?

I found maybe a related topic on this at
https://groups.google.com/d/topic/foreman-users/sZKU0P0Td5M ?

Thanks in advance.

Just to follow-up, here is the message from production.log when the host
first checks in:

Started POST "/api/hosts/facts" for 192.168.100.22 at 2014-03-21 10:29:16
+0000
Processing by Api::V2::HostsController#facts as JSON
Parameters: {"name"=>"localhost.internal.mydomain.com",
"certname"=>"test1.internal.mydomain.com", "facts"=>"[FILTERED]",
"apiv"=>"v2", "host"=>{"name"=>"localhost.internal.mydomain.com",
"certname"=>"test1.internal.mydomain.com", "facts"=>"[FILTERED]"}}
Import facts for 'localhost.internal.mydomain.com' completed. Added: 91,
Updated: 0, Deleted 0 facts
Completed 201 Created in 564ms (Views: 5.9ms | ActiveRecord: 0.0ms)

The certname is set correctly, but any idea where the "name" value is set?

After the server finishes the build and is rebooted, "name" correctly
matches "certname", so it's just in the kickstart phase when the following
is run:

/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags
no_such_tag <%= @host.puppetmaster.blank? ? '' : "–server
#{@host.puppetmaster}" %> --no-daemonize

Richard.

What about "facter fqdn" ?

··· On 21 March 2014 09:15, Richard wrote: > [root@test1 etc]# facter| grep host > hostname => test1

Thanks Greg. I've managed to fix this by updating the kickstart as follows:

Setup puppet to run on system reboot

/sbin/chkconfig --level 345 puppet on
hostname <%= @host %>
/usr/bin/puppet agent --config /etc/puppet/puppet.conf -o --tags
no_such_tag <%= @host.puppetmaster.blank? ? '' : "–server
#{@host.puppetmaster}" %> --no-daemonize

It seemed as though when the server was running the %post scripts it had
"localhost.internal.mydomain.com" being returned by hostname. The above
fix explicitly sets it prior to running puppet for the first time.

So far, so good.

··· On Friday, 21 March 2014 12:59:49 UTC, Greg Sutcliffe wrote: > > On 21 March 2014 09:15, Richard <ric...@richii.co.uk > > wrote: > > [root@test1 etc]# facter| grep host > > hostname => test1 > > What about "facter fqdn" ? >