Are any of global params available for use in global pxelinux/pxegrub templates?

provisioning

#1

Problem:

It seems that I can’t reference any of the global parameters in global templates because those params are considered to be “host”-level params in contrary to the name (global).

Expected outcome:

Am I missing something and there’s indeed a way to use those params?

Another question on the params topic - is there a command and/or macro to get all of available variables/params in each kind of templates so I can see all of them? Something like “get_all_vars” or alike…

Thanks!


#2

You pretty much described the constraint here. There is no host available, therefore no host parameters can be accessed.

Another bad news - nope. Feel free to add a helper.


#3

Right, I understand that no host params available, but these are global params, like foreman_server_url - why some such params are available and the others are not? Any plans to fix this in upcoming versions?

Thanks!


#4

I guess the most confusing part here is that “Global Parameters” are named somewhat missleading. Actually, those are more like “Global Host Parameters”, parameters that get attached to all your hosts with a global default.
Variables like foreman_server_url are actually no parameters. You can not set most of those and the ones you can change, you probably should not.
I doubt there is currently a way to set some really global parameters that can be queried without a host object.


#5

These are functions, we like to call them macros. They are defined in the codebase. What exectly do you need?


#6

Well, I was hoping to pass some params (like root password) to global default pxelinux and pxegrub2 templates, which in my case are loading FDI-like in-memory netbooted OS.

Not a show stopper, I was just hoping not to keep passwords hardcoded (even though they are encrypted) in templates’ repo.

My next exercise is an ability for a user, who provisions a system through Foreman UI or API, to pass an arbitrary key:value param(s) that would be picked up by postinstall and handled one way or the other.

An example is a param called “user_postinstall” with a value set to some URL (reachable by said system at the time of provisioning, of course). The real postinstall template (finish kind) would have a snippet in it or something that would result in a code like “curl | bash > user_postinstall.log 2>&1” if “user_postinstall” param present and resolves to an URL.

This should work, shouldn’t it?


#7

Foreman have a “hidden” template kind called “Script template”. Create an arbitrary shell script, associate with our OS and then use this in curl or wget. Remember to use token if you have them enabled, that’s the default:

$ wget -q -O- http://localhost:5000/unattended/script?token=a2eac0b8-1ccc-4419-889b-ee58f6864593