Retrieve smart_proxies hostnames in templates

Hi all,
We use foreman_discovery plugin in our deployments, and we use one smart_proxy per "location", that proxy all communications to foreman and manage local stuff (discovery, dhcp, puppetmaster…). I set "proxy.url=https://foreman-proxy01.foo.example.com:8443 proxy.type=proxy" option to my default PXE template to test discovery from this smart proxy, but i wanted to handle it more genericaly for example "proxy.url=<%= smart_proxies[:tftp].url %> proxy.type=proxy" or something like that, but i don't want to have to add DNS entry for this stuff because we have a lot of DNS domains/subdomains and i wanted to handle this in one place.

There is any way to achieve this use case today ?

Have a nice day.

··· -- Baptiste

No, it's not possible if you're talking about the default PXELinux
template as it's only rendered once and sent to all proxies.

There was some work started in
Bug #10286: Default PXE Menu should be isolated - Foreman (the linked PR) but it
wasn't completed.

··· On 13/11/15 11:31, Baptiste Agasse wrote: > Hi all, > We use foreman_discovery plugin in our deployments, and we use one smart_proxy per "location", that proxy all communications to foreman and manage local stuff (discovery, dhcp, puppetmaster...). I set "proxy.url=https://foreman-proxy01.foo.example.com:8443 proxy.type=proxy" option to my default PXE template to test discovery from this smart proxy, but i wanted to handle it more genericaly for example "proxy.url=<%= smart_proxies[:tftp].url %> proxy.type=proxy" or something like that, but i don't want to have to add DNS entry for this stuff because we have a lot of DNS domains/subdomains and i wanted to handle this in one place. > > There is any way to achieve this use case today ?


Dominic Cleal
dominic@cleal.org

Hi,

>> Hi all,
>> We use foreman_discovery plugin in our deployments, and we use one smart_proxy
>> per "location", that proxy all communications to foreman and manage local stuff
>> (discovery, dhcp, puppetmaster…). I set
>> "proxy.url=https://foreman-proxy01.foo.example.com:8443 proxy.type=proxy"
>> option to my default PXE template to test discovery from this smart proxy, but
>> i wanted to handle it more genericaly for example "proxy.url=<%=
>> smart_proxies[:tftp].url %> proxy.type=proxy" or something like that, but i
>> don't want to have to add DNS entry for this stuff because we have a lot of DNS
>> domains/subdomains and i wanted to handle this in one place.
>>
>> There is any way to achieve this use case today ?
>
> No, it's not possible if you're talking about the default PXELinux
> template as it's only rendered once and sent to all proxies.
>
> There was some work started in
> Bug #10286: Default PXE Menu should be isolated - Foreman (the linked PR) but it
> wasn't completed.

Ok, thank you, and for more general templates, like kickstart. For example to add repo for installation mirrored by pulp on the proxy, CentOS6 don't include subscription manager, so we have to add a repo. I've an error "undefined method 'smart_proxies' for Host::Managed::Jail (Host::Managed)" (safe mode is active) when I call @host.smart_proxies in kickstart template.

··· ----- Le 13 Nov 15, à 12:40, Dominic Cleal dominic@cleal.org a écrit : > On 13/11/15 11:31, Baptiste Agasse wrote:


Dominic Cleal
dominic@cleal.org


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 http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/d/optout.


Baptiste AGASSE
Lyra Network, Expert Systèmes GNU/Linux
109 Rue de l’innovation, 31670 Labège - France
Tél: (+33)5.67.22.31.87
Fax: (+33)5.67.22.31.61
Mail: baptiste.agasse@lyra-network.com
Site: http://www.lyra-network.com

Method calls are protected by default by a gem called safemode. This
can be customised very easily in the source by adding method names to
the Jail classes (e.g. at
https://github.com/theforeman/foreman/blob/1.10.0-RC2/app/models/host/managed.rb#L67).

Probably to access the TFTP smart proxy details you'd want to access
@host.provision_interface.subnet.tftp_proxy.url or .hostname.

I think this would need tftp_proxy adding to the subnet Jail and a jail
adding to the SmartProxy class with url/hostname. Patches in this area
are very welcome, it's trivial to do and can be very helpful.

You can also disable safemode under settings, but it allows arbitrary
code execution - definitely not recommended.

··· On 13/11/15 14:11, Baptiste Agasse wrote: > Hi, > > ----- Le 13 Nov 15, à 12:40, Dominic Cleal dominic@cleal.org a écrit : > >> On 13/11/15 11:31, Baptiste Agasse wrote: >>> Hi all, >>> We use foreman_discovery plugin in our deployments, and we use one smart_proxy >>> per "location", that proxy all communications to foreman and manage local stuff >>> (discovery, dhcp, puppetmaster...). I set >>> "proxy.url=https://foreman-proxy01.foo.example.com:8443 proxy.type=proxy" >>> option to my default PXE template to test discovery from this smart proxy, but >>> i wanted to handle it more genericaly for example "proxy.url=<%= >>> smart_proxies[:tftp].url %> proxy.type=proxy" or something like that, but i >>> don't want to have to add DNS entry for this stuff because we have a lot of DNS >>> domains/subdomains and i wanted to handle this in one place. >>> >>> There is any way to achieve this use case today ? >> >> No, it's not possible if you're talking about the default PXELinux >> template as it's only rendered once and sent to all proxies. >> >> There was some work started in >> http://projects.theforeman.org/issues/10286 (the linked PR) but it >> wasn't completed. > > Ok, thank you, and for more general templates, like kickstart. For example to add repo for installation mirrored by pulp on the proxy, CentOS6 don't include subscription manager, so we have to add a repo. I've an error "undefined method 'smart_proxies' for Host::Managed::Jail (Host::Managed)" (safe mode is active) when I call @host.smart_proxies in kickstart template.


Dominic Cleal
dominic@cleal.org