Bare metal provision without PXE

Hello all,

I’m new to Foreman and I’m working on a setup where I cannot use PXE for auto-discovery. I read here that you can re-provision an existing server by calling the appropriate template, something like ‘http://yourforeman.domain/unattended/provision?spoof=xx.yy.zz.xx’ (this is just to render the template)

I have the following questions:

  1. How you can see all the available provisioning templates? I see the files on /usr/share/foreman/app/views.unattended/provisioning_templates but it is not clear to me how this are mapped to the one I see on the Web UI (https://yourforeman.domain/templates/provisioning_templates)
  2. My example https://yourforeman.domain/unattended/provision?spoof=xx.yyy.zzz.xx gives me an error “# unattended: unable to find a host that matches the request from xx.yyy.zzz.xx
  3. My foreman server is on a different subnet than the server I need to provision. I enabled ‘Token duration=largeValue’ on settings, will this be enough for Foreman to work?

I’m using the 14.0 version of the discovery plugin and Foreman ‘1.21.2’.

Thanks in advance, I can provide more details if required.

Hello,

  1. Associate “script” template with the OS your host uses. You need to do this in Provisioning Templates screen Associate tab and then in Operating System - Templates tab.
  2. The template you want is called Grubby default (it’s quite old not sure if it will work - you might need to customize it)
  3. Put your host into Build mode by clicking on the Build button (this will generate token)
  4. On the host detail on the left side, copy the UUID token
  5. You can use Templates tab and preview Script template to see it in advance and test it
  6. Once you are happy with the result just perform curl http://foreman.example.com/unattended/script?token=UUID | bash and reboot. You can use Remote Execution for that.

If you find any problems with the template, feel free to update it here. Also get back to me with feedback, we should probably post an updated version of that old blogpost. It is also technically possible to create a Remote Execution template which will render the curl command including the token automatically so this process can be fully automated.

Hello, thanks for the update. Let me try your suggestions and I will share my results here.

I have tested it with Foreman 1.20 and it works fine without any changes. I also implemented Remote Execution job to do the very same: https://github.com/theforeman/foreman/pull/7022

Have fun!