Spoof by MAC address?

Hi,

I'm trying to setup a foreman/puppet setup with which I want to bootstrap
and install computers (virtuals) for which I do no know the IP address.

What I have sofar is that I created an ipxe bootable iso image with an
embedded script.
My idea is that if I know the MAC of the system I have enough information
to retrieve the relevant info for the host; foreman already enforces unique
mac addresses.

My question is simply: Can I retrieve the boot info by specifying just the
MAC address (the IP is dynamic) similar to what the ?spoof= does for the ip
address?

Niels Basjes

Note that spoofing by hostname would also be useful in the "I don't know
the IP address" scenario.

··· On Wednesday, September 25, 2013 4:15:21 PM UTC+2, Niels Basjes wrote: > > Hi, > > I'm trying to setup a foreman/puppet setup with which I want to bootstrap > and install computers (virtuals) for which I do no know the IP address. > > What I have sofar is that I created an ipxe bootable iso image with an > embedded script. > My idea is that if I know the MAC of the system I have enough information > to retrieve the relevant info for the host; foreman already enforces unique > mac addresses. > > My question is simply: Can I retrieve the boot info by specifying just the > MAC address (the IP is dynamic) similar to what the ?spoof= does for the ip > address? > > Niels Basjes >

First things first. the ?spoof=<ip> url is only for humans to check that
templates render. Don't use it in a template or a script, as spoofing
causes orchestration actions to be skipped. Use /unattended/provision for
your scripts.

With that in mind, you have a few options. Firstly, and probably best in
your case, Foreman will use the MAC if it's present as a Header in the web
request. Try setting:

HTTP_X_RHN_PROVISIONING_MAC_0 = <mac>

when you download /unattended/provision, and it should work.

Failing that, I'd look at the brand-new foreman_bootiso plugin, in
combination with token-based provisioning, to create a bootable ISO to
build a host direct from Foreman. You can find out more about
foreman_bootiso at

As a final fallback, you can always use the API - search for hosts by MAC,
then update the IP in foreman with whatever DHCP gave you, and then GET
/unattended/provision

HTH,
Greg

··· On 25 September 2013 15:49, Niels Basjes wrote:

Note that spoofing by hostname would also be useful in the “I don’t know
the IP address” scenario.

Hi Greg,

Thanks for the input. This boot disk iso looks very promising.
I created a quick local patch that allows for a ?mac= parameter and
locates the host using that.
I combined that with a ipxe.iso that contains the embedded script:
#!ipxe
:retry_dhcp
echo Trying DHCP
dhcp || goto retry_dhcp
chain http://foreman.basjes.lan/unattended/gPXE?mac=${net0/mac} ||
sanboot --no-describe --drive 0x80
boot

I currently have the problem that somehow a new host is created the
first time puppet runs.
This host has a different hostname compared to the configured
hostname, but it does have the same MAC adress.

Q: Where does the code path start that adds this hostname?

Niels

··· On Wed, Sep 25, 2013 at 4:58 PM, Greg Sutcliffe wrote: > On 25 September 2013 15:49, Niels Basjes wrote: >> >> Note that spoofing by hostname would also be useful in the "I don't know >> the IP address" scenario. > > > First things first. the ?spoof= url is only for humans to check that > templates render. Don't use it in a template or a script, as spoofing causes > orchestration actions to be skipped. Use /unattended/provision for your > scripts. > > With that in mind, you have a few options. Firstly, and probably best in > your case, Foreman will use the MAC if it's present as a Header in the web > request. Try setting: > > HTTP_X_RHN_PROVISIONING_MAC_0 = > > when you download /unattended/provision, and it should work. > > Failing that, I'd look at the brand-new foreman_bootiso plugin, in > combination with token-based provisioning, to create a bootable ISO to build > a host direct from Foreman. You can find out more about foreman_bootiso at > http://blog.theforeman.org/2013/09/foreman-community-newsletter-september.html > > As a final fallback, you can always use the API - search for hosts by MAC, > then update the IP in foreman with whatever DHCP gave you, and then GET > /unattended/provision > > HTH, > Greg > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Foreman users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/foreman-users/FepJimPBvcY/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/groups/opt_out.


Best regards / Met vriendelijke groeten,

Niels Basjes