New setting in foreman_discovery for the hostname source of the discovered host

Hi,
Will it be possible to change hard-coded "macaddress_eth0" fact name that
define default name of the discovered host to be custom name that is set in
the Foreman settings?
It can be by default "macaddress_eth0", but I use discovery_init.sh
script to setup some additional facts before they are imported into
Foreman, and I want to use one of my facts to be a new default hostname as
it allow me to easier identify discovered hosts.
Also some of my hosts do not have eth0 so hard-coded "macaddress_eth0"
basically doesn't work very well with some machines.
At the moment hard-coded fact name is in the file
app/models/host/discovered.rb.

Many thanks,
Tomasz

I experimented with using "macaddress" instead, but the TCL image creates a
"dummy" interface that Facter seems to prefer over the real interface.

I think a good way forward is probably not to rely on a Fact at all, but to
add an API parameter to Discovers#create, and then discover the correct
device in the bin/discover_host script. We could also add an optional
kernel cmdline override as well, for when the discovery image is somehow
getting it wrong.

How does that sound?

··· On 18 October 2013 16:49, wrote:

Hi,
Will it be possible to change hard-coded “macaddress_eth0” fact name
that define default name of the discovered host to be custom name that is
set in the Foreman settings?
It can be by default “macaddress_eth0”, but I use discovery_init.sh
script to setup some additional facts before they are imported into
Foreman, and I want to use one of my facts to be a new default hostname as
it allow me to easier identify discovered hosts.
Also some of my hosts do not have eth0 so hard-coded "macaddress_eth0"
basically doesn’t work very well with some machines.
At the moment hard-coded fact name is in the file
app/models/host/discovered.rb.

Sounds good.
I assume I would be able to decide in my custom discovery_init.sh script
what host name I want to register in Foreman with that API.
I have a requirement in my environment to use serial number as a host name
for some specific subnets, and for other machines host name will be entered
from the keyboard - custom bash code in the discovery_init.sh script (as
the hostname is determined by the label attached to the machine).

Tomasz

··· On Friday, October 18, 2013 4:57:32 PM UTC+1, Greg Sutcliffe wrote: > > On 18 October 2013 16:49, <tomasz....@gmail.com > wrote: > >> Hi, >> Will it be possible to change hard-coded "macaddress_eth0" fact name >> that define default name of the discovered host to be custom name that is >> set in the Foreman settings? >> It can be by default "macaddress_eth0", but I use discovery_init.sh >> script to setup some additional facts before they are imported into >> Foreman, and I want to use one of my facts to be a new default hostname as >> it allow me to easier identify discovered hosts. >> Also some of my hosts do not have eth0 so hard-coded "macaddress_eth0" >> basically doesn't work very well with some machines. >> At the moment hard-coded fact name is in the file >> app/models/host/discovered.rb. >> > > I experimented with using "macaddress" instead, but the TCL image creates > a "dummy" interface that Facter seems to prefer over the real interface. > > I think a good way forward is probably not to rely on a Fact at all, but > to add an API parameter to Discovers#create, and then discover the correct > device in the bin/discover_host script. We could also add an optional > kernel cmdline override as well, for when the discovery image is somehow > getting it wrong. > > How does that sound? >

Overriding the hostname makes sense. I've raised
Feature #3371: Customize the data used to select the hostname for a discovered host - Discovery - Foreman for us to chat more on.

··· On 18 October 2013 19:37, wrote:

Sounds good.
I assume I would be able to decide in my custom discovery_init.sh script
what host name I want to register in Foreman with that API.
I have a requirement in my environment to use serial number as a host name
for some specific subnets, and for other machines host name will be entered
from the keyboard - custom bash code in the discovery_init.sh script (as
the hostname is determined by the label attached to the machine).

Tomasz