Custom variables in templates

Hello,

I would like to run Foreman in a distributed, multi-site setup. Each site
has a dedicated dhcp+tftp smart proxy, including a Windows WDS host.
I am in need to provide a "boot from WDS" menu item in the PXE menu. That
is easy, but each proxy should provide a PXE menu customized to point at
the site-specific WDS.

Two options I thought of:

  • DNS based solution, with same url but changing IP by site
  • A variable (@wds_server_ip) in the PXE file, associated to a host
    group, different per site

Now, this second option is tempting but I can't figure out how to make it
happen: I have been kindly pointed at the Functions/Macros section of the
wiki. Sadly, host/hostgroup specific parameters don't apply to global PXE
templates (see here
TemplateWriting - Foreman).

I would love to find a solution to this, since also the Discovery PXE
snippet has an hardcoded smart-proxy value, and I need that to be dynamic
per site.

Thanks!

Unfortunately, global PXE templates are "dumb", there is no magic in
there and no host/hostgroup associations. They are simple templates as
simple as file copy can be. At least at the moment, this may change in
the future (send a patch :slight_smile:

LZ

··· On Thu, Nov 10, 2016 at 10:02 PM, Alexander Rilik wrote: > Hello, > > I would like to run Foreman in a distributed, multi-site setup. Each site > has a dedicated dhcp+tftp smart proxy, including a Windows WDS host. > I am in need to provide a "boot from WDS" menu item in the PXE menu. That is > easy, but each proxy should provide a PXE menu customized to point at the > site-specific WDS. > > Two options I thought of: > > DNS based solution, with same url but changing IP by site > A variable (@wds_server_ip) in the PXE file, associated to a host group, > different per site > > Now, this second option is tempting but I can't figure out how to make it > happen: I have been kindly pointed at the Functions/Macros section of the > wiki. Sadly, host/hostgroup specific parameters don't apply to global PXE > templates (see here > http://projects.theforeman.org/projects/foreman/wiki/templatewriting#PXE-Menus). > > I would love to find a solution to this, since also the Discovery PXE > snippet has an hardcoded smart-proxy value, and I need that to be dynamic > per site. > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "Foreman users" group. > To unsubscribe from this group and stop receiving emails from it, 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 https://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/d/optout.


Later,
Lukas @lzap Zapletal

Ouch, I see! Thanks for confirming.
Would you recommend any workaround via Foreman, in the meantime?

I have two solutions, so far, that don't involve Foreman, but I'd like to
rely on it instead:

  • Point to a WDS url which returns a different IP based on the site (as
    explained in previous message)
  • Use Puppet to generate the PXE config, changing the url by site based on
    local facts
··· On Monday, November 14, 2016 at 12:25:54 PM UTC+1, Lukas Zapletal wrote: > > Unfortunately, global PXE templates are "dumb", there is no magic in > there and no host/hostgroup associations. They are simple templates as > simple as file copy can be. At least at the moment, this may change in > the future (send a patch :-) >

Use a Parameter you can set them on an Organisation, Location, operating
system, subnet, host group and host. They have a priority so you can
override them at points*. You could get access them from the template using
@host.params['<param-name>'] so when the hosts PXE template is generated it
would be set to what ever that param is set to for that host.

  • sorry I can't remember he priory right now!
··· On Mon, 14 Nov 2016 at 11:59, Alexander Rilik wrote:

On Monday, November 14, 2016 at 12:25:54 PM UTC+1, Lukas Zapletal wrote:

Unfortunately, global PXE templates are “dumb”, there is no magic in
there and no host/hostgroup associations. They are simple templates as
simple as file copy can be. At least at the moment, this may change in
the future (send a patch :slight_smile:

Ouch, I see! Thanks for confirming.
Would you recommend any workaround via Foreman, in the meantime?

I have two solutions, so far, that don’t involve Foreman, but I’d like to
rely on it instead:

  • Point to a WDS url which returns a different IP based on the site (as
    explained in previous message)
  • Use Puppet to generate the PXE config, changing the url by site based on
    local facts


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, 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 https://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.

See Foreman :: Manual under
Global parameters.

··· On 14/11/16 20:48, Sean O'Keeffe wrote: > Use a Parameter you can set them on an Organisation, Location, operating > system, subnet, host group and host. They have a priority so you can > override them at points*. You could get access them from the template > using @host.params[''] so when the hosts PXE template is > generated it would be set to what ever that param is set to for that host. > > * sorry I can't remember he priory right now!


Dominic Cleal
dominic@cleal.org