Thanks for the reply Greg,

I am looking to consume the data through the API, and your docs link and 
the term 'ENC data' (which is new to me) helped me find the answer.

The docs on parameters mention at the end of section 4.2.3:
"To see how Foreman is passing the parameters to Puppet, go to a Host and 
click the YAML button. You will be shown the exact YAML data sent to the 
Puppet master - the parameters will be in the “parameters” hash."

The short version of my question was, how do I get that data from the API? 
The answer is via /api/hosts/<id>/enc

Many thanks for solving an issue that has been plaguing me for most of the 
week!
Brian


On Friday, July 7, 2017 at 10:21:45 AM UTC+1, Greg Sutcliffe wrote:
>
> On Wed, 2017-07-05 at 08:45 -0700, Brian McArdle wrote: 
> > Is my understanding above all correct? Is there a shortcut that I'm 
> > missing to finding out what values a host is using for a class? 
>
> It's already in the ENC data that Foreman sends to Puppet (assuming the 
> host is in the hostgroup in question). When the ENC YAML is compiled, 
> Foreman will parse the parameters from least specific to most specific, 
> overriding ones with the same name as it goes. So if your hostgroup has 
> "class foo -> parameter bar = quux" you should see that on your host 
> directly (check the YAML button on the host page). But if the host has 
> "class foo -> parameter bar = qaaz" then you'll see that instead. The 
> exact hierarchy is listed in the manual, see: 
>
> https://theforeman.org/manuals/1.15/#4.2.3Parameters 
>
> You don't actually say *where* you're trying to consume this data 
> though. I assume you're wanting it in Puppet, which should work out of 
> the box - anything in the ENC is passed to Puppet and should be used 
> directly. If you want to access it in templates, you can use "<%= 
> host_enc %>" (via http://projects.theforeman.org/projects/foreman/wiki/ 
> TemplateWriting#Functions-and-macros 
> <http://projects.theforeman.org/projects/foreman/wiki/TemplateWriting#Functions-and-macros>),
>  
> and from some other place, there 
> is an API call to get the host's ENC data (GET /api/hosts/:id/enc) 
>
> If want to access data for other hosts / hostgroups in Puppet 
> manifests, there are ways - but for brevity I'll not go into to that 
> yet. If that's what you're actually looking for, shout out :) 
>
> Greg 
>

-- 
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+unsubscr...@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.

Reply via email to