Puppet master ip in provisioning template

Hello,

Is there a way to get the puppet master IP from a provisioning template
(finish or userdata)?

I'm using <%= @host.puppetmaster %> to get the fqdn but I don't find
anything to get the management IP (host cannot resolve)

Thanks,

Anthony

There's no guarantee the puppetmaster is in Foreman's db - it gets the fqdn
from the puppet proxy assigned to the host, from the smart proxies table.
Assuming it is in the db, you could do something like:

<%= Host.find(@host.puppetmaster).ip %>

but that will almost certianly require you to disable safe_mode in the
settings - something we don't generally recommend.

Greg

··· On 25 January 2016 at 10:37, Anthony Chevalet wrote:

Hello,

Is there a way to get the puppet master IP from a provisioning template
(finish or userdata)?

I’m using <%= @host.puppetmaster %> to get the fqdn but I don’t find
anything to get the management IP (host cannot resolve)

Thanks a lot Greg, it is working fine!

Any chance to have a supported macro in a future version?

··· Le lundi 25 janvier 2016 13:10:53 UTC+1, Greg Sutcliffe a écrit : > > On 25 January 2016 at 10:37, Anthony Chevalet > wrote: > >> Hello, >> >> Is there a way to get the puppet master IP from a provisioning template >> (finish or userdata)? >> >> I'm using <%= @host.puppetmaster %> to get the fqdn but I don't find >> anything to get the management IP (host cannot resolve) >> > > There's no guarantee the puppetmaster is in Foreman's db - it gets the > fqdn from the puppet proxy assigned to the host, from the smart proxies > table. Assuming it *is* in the db, you could do something like: > > <%= Host.find(@host.puppetmaster).ip %> > > but that will almost certianly require you to disable safe_mode in the > settings - something we don't generally recommend. > > Greg >

Personally I think it's tricky since there's no requirement to know
anything about the puppetmaster - but others may have solutions I've not
thought of. Feel free to raise a ticket if you like :slight_smile:

http://projects.theforeman.org/projects/foreman/issues/new

Greg

··· On 25 January 2016 at 15:36, Anthony Chevalet wrote:

Thanks a lot Greg, it is working fine!

Any chance to have a supported macro in a future version?