Using Hammer or API to render kickstart files

Hello,

Is it possible to use foreman to render+download a kickstart file using
hammer (or API) and feeding in the necessary info, e.g. the
provisioning+partition templates to use? If necessary I can feed in dummy
data (e.g. host's name) to generate the rendered kickstart file.

I am trying to do this to generate a sample kickstart file which I can then
feed into my packer project in order to create new vmware templates.

Thanks,
Sher

So your goal is to pass data into Foreman to render a template on the
fly, for a given hostname/ip/etc?

That's not possible today - you can only get templates for Hosts that
exist (and not by Hammer, iirc, although you can get the "review" URL
with curl directly if you're logged in). I guess you could either (a)
create a Host for your template and replace the placeholder data in
the rendered template, or (b) create Hosts with Hammer as required and
then retrieve your template (presumably with unmanaged NICs so that
DHCP/DNS/etc records are not created).

Cheers,
Greg

··· On 24 November 2015 at 19:23, Sher Chowdhury wrote: > Hello, > > Is it possible to use foreman to render+download a kickstart file using > hammer (or API) and feeding in the necessary info, e.g. the > provisioning+partition templates to use? If necessary I can feed in dummy > data (e.g. host's name) to generate the rendered kickstart file. > > I am trying to do this to generate a sample kickstart file which I can then > feed into my packer project in order to create new vmware templates.

Thanks Greg, Dominic,

In that case I think I'll be able to wait for this new API feature.

In the meantime I can create a dummy host purely to retrieve it's rendered
kickstart file. I think I might then be able to use curl to download the
rendered kickstart file. I'll give this I try some time next week and
report back on how it goes.

Thanks again,
Sher

It probably won't help you right now, but I ought to mention that an API
for previewing templates to match the web UI has been added in our
develop branch for Foreman 1.11.

This will allow you to call
/api/v2/hosts/foo.example.com/template/provision to retrieve a copy of
the provision (preseed/kickstart) template for the host. It won't
perform any of the usual provisioning actions that occur when the host
calls the real template, e.g. realm or PuppetCA integration. It also
requires a host to be in Foreman to query.

··· On 24/11/15 19:23, Sher Chowdhury wrote: > Hello, > > Is it possible to use foreman to render+download a kickstart file using > hammer (or API) and feeding in the necessary info, e.g. the > provisioning+partition templates to use? If necessary I can feed in > dummy data (e.g. host's name) to generate the rendered kickstart file.


Dominic Cleal
dominic@cleal.org