Use facts in smart variables

Hi there,

I'm a total neeby when it comes to puppet and foreman. So far I'm very
happy with my setup and configuration rollout tests. One problem I'm unable
to solve is using facts in a puppet class.

Here's an example:

I use the saz/ssh puppet module to configure my SSH servers. Everything
works fine except defining the ListenAddress. I want to assing the
ListenAddress the fact 'ipaddress_eth1' but no matter what I try - I'm
unable to get it work.

Markus

You need to use ERB in the class parameter value, so something like
<%= @hosts.facts_hash['ipaddresss_eth1'] %> should work. You can click
the YAML button on the Host's page to check it's working.

Greg

··· On 29 July 2014 06:17, hirnschmalz wrote: > Hi there, > > I'm a total neeby when it comes to puppet and foreman. So far I'm very happy > with my setup and configuration rollout tests. One problem I'm unable to > solve is using facts in a puppet class. > > Here's an example: > > I use the saz/ssh puppet module to configure my SSH servers. Everything > works fine except defining the ListenAddress. I want to assing the > ListenAddress the fact 'ipaddress_eth1' but no matter what I try - I'm > unable to get it work. > > Markus

>
>
> You need to use ERB in the class parameter value, so something like
> <%= @hosts.facts_hash['ipaddresss_eth1'] %> should work. You can click
> the YAML button on the Host's page to check it's working.
>

Hi Greg,

I got it working with <%= @host.ip %> (without the trailing 's' at
@host). But when i try to use <%= @host.facts_hash['ipaddresss_eth1'] %> I
got the following error in the log:

Failed to generate external nodes for XXX with undefined method
'facts_hash' for Host::Managed::Jail (Host::Managed)

Any hints for me? It would be much better in this case if I could use a
defined ehternet device.

Markus

You'll need to disable Safemode Rendering in the Settings page of the
UI to move past that error, as the facts_hash call is not currently
whitelisted.

Greg

··· On 29 July 2014 11:51, hirnschmalz wrote: >> >> You need to use ERB in the class parameter value, so something like >> <%= @hosts.facts_hash['ipaddresss_eth1'] %> should work. You can click >> the YAML button on the Host's page to check it's working. > > > Hi Greg, > > I got it working with <%= @host.ip %> (without the trailing 's' at @host). > But when i try to use <%= @host.facts_hash['ipaddresss_eth1'] %> I got the > following error in the log: > > Failed to generate external nodes for XXX with undefined method 'facts_hash' > for Host::Managed::Jail (Host::Managed) > > Any hints for me? It would be much better in this case if I could use a > defined ehternet device. > > > Markus > > -- > 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.

>
> You'll need to disable Safemode Rendering in the Settings page of the
> UI to move past that error, as the facts_hash call is not currently
> whitelisted.
>

Hi Greg,

thank you very much - you saved my day :slight_smile:

Markus