Use parameters to set build form values

We would like to know if it is possible to set a parameter (assigned to an organization for example) and have that populate a field on a create host form.

Currently we have Host Groups configured for OS and OS Version. these are shared across multiple Organizations. we would like to assign parameters to the Organization that would ‘auto-populate’ the vLAN / Subnet as well as target the specific vSphere folder on the form specific to that organization to minimize the number of clicks an end user has to make to submit a ‘Create Host’ request.

any ideas if this is possible or is there a better way to achieve this?

In general, setting parameters depending on another parameter is possible via in-line erb templating. Though, for your specific use-case, that’s not possible due to the fact that vLAN/Subnet and vSphere folder are drop downs and not text fields.
Afaik, this specific use-case is currently not possible, due to the fact that the vLAN and folder defaults come from the compute profile, which is turn is only scoped to the compute resource and not to the organization.

do you think even though these are dropdowns that it could be possible in a kickstart/snippet to leverage any parameters to set these on build? Would we have to see what the actual syntax of the contents in the dropdown is (if there is a difference) so we could have the parameters match what is in the dropdown? that way on all the host groups we could just have those fields be set to a dummy setup but leverage the parameters for the AD group to populate that data for the acutal build.

i feel like there has to be some way to make this happen

Well, it’s at least not possible with Foreman core tooling I guess.
In kickstart templates, you can basically do anything (as long as the required commands are there), but that is probably a step to late. My best bet would be to take a look at webhook and maybe shellhooks plugins. Those are probably in some way or another able to solve your problem at hand, but you will have to write some code and/or API calls yourself.

Those are probably in some way or another able to solve your problem at hand, but you will have to write some code and/or API calls yourself.

yeah. i have been looking at possibly making a powershell ‘sorting’ script to do the following:

  • connect to foreman via api
  • pull the new host name, (maybe all the host names), and set parameters
  • use the parameter information to do a powercli call to vCenter and sort the vm’s into their respective folders.

at least until something better comes along.