Use facts in smart-variable values

>
> Hi!
>
> Can I use facts a values for parametrized classes?
>
> Here my scenario:
> I have a class, where the default value of a class is $hostname. For a
> some hosts, I want to override it.
>
> When I import the class, in Foreman it defaults to ${$hostname}. When I
> click on override, the resulting YAML file für the ENC contains the string
> ${$hostname}, which is then used within the manifests without being
> interpolated.*
> *
> I tried anything, at least a lot of things, as default value ($hostname,
> $$hostname, ${hostname}), but I always results in this specific string
> within the manifest and not the value of the fact. *
>
> *
> Is this possible with foreman?
>
>
Do you mean something like?

param name = ntp_sever
param_value = ntp.$domain ?

Ohad

··· On Monday, 26 November 2012 20:06:36 UTC+2, Florian Sachs wrote:

best regards,
florian*
*

ForemanVersion: 1.0.1-7 - RPM Package from 2012-11-21, devel-yum
repository - everything installed via rpm
Platform: RedHat 6.3 x86_64
Postgresql: 9.2
Puppet: 3.0.1

> Hi! sorry for jumping in, and at first thanks for great product.
>
> I got the same question = we are now migrating to Foreman ENC from ldap
> and in LDAP we had one more parameter named ipHostNumber. I dont want to
> copy it, so i tried to add smart variable something like ipHostNumber =
> facts.ipaddress
>
> sure, just use as a matcher
ipaddress = 'your ip'

any fact or something that foreman knows about (even another param) can be
used as a key on the left side of the matcher.

Ohad

··· On Mon, Dec 3, 2012 at 6:52 PM, Andrei Burd wrote:

Is it possible? can smart variable be assigned from facts?

On Wednesday, November 28, 2012 9:08:29 AM UTC+2, ohad wrote:

On Monday, 26 November 2012 20:06:36 UTC+2, Florian Sachs wrote:

Hi!

Can I use facts a values for parametrized classes?

Here my scenario:
I have a class, where the default value of a class is $hostname. For
a some hosts, I want to override it.

When I import the class, in Foreman it defaults to ${$hostname}. When
I click on override, the resulting YAML file für the ENC contains the
string ${$hostname}, which is then used within the manifests without
being interpolated.*
*
I tried anything, at least a lot of things, as default value ($hostname,
$$hostname, ${hostname}), but I always results in this specific string
within the manifest and not the value of the fact. *

Is this possible with foreman?

Do you mean something like?

param name = ntp_sever
param_value = ntp.$domain ?

Ohad

best regards,
florian*
*

ForemanVersion: 1.0.1-7 - RPM Package from 2012-11-21, devel-yum
repository - everything installed via rpm
Platform: RedHat 6.3 x86_64
Postgresql: 9.2
Puppet: 3.0.1


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/foreman-users/-/rI6By9YeLO4J.

To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

@ohadlevey I think the question is, can Facts be passed as the answer,
not as the the matcher. I.e given these Facts:

hostname = foo
ip = 1.2.3.4

you might want to do

Matcher: fqdn = 'foo'
Value: $ip

and have the ENC Yaml for 'foo' display:

classes:
bar:
quux: 1.2.3.4

As it stands, I don't think we can do this today - the param class
support only sends static text to the ENC, right?

··· On 3 December 2012 17:25, Ohad Levy wrote: > > > > On Mon, Dec 3, 2012 at 6:52 PM, Andrei Burd wrote: >> >> Hi! sorry for jumping in, and at first thanks for great product. >> >> I got the same question = we are now migrating to Foreman ENC from ldap >> and in LDAP we had one more parameter named ipHostNumber. I dont want to >> copy it, so i tried to add smart variable something like ipHostNumber = >> facts.ipaddress >> > sure, just use as a matcher > ipaddress = 'your ip' > > any fact or something that foreman knows about (even another param) can be > used as a key on the left side of the matcher. > > Ohad

You got it right!
The point is to force Foreman to send a fact as a value.

··· On Monday, December 3, 2012 8:45:21 PM UTC+2, Greg Sutcliffe wrote: > > On 3 December 2012 17:25, Ohad Levy <ohad...@gmail.com > > wrote: > > > > > > > > On Mon, Dec 3, 2012 at 6:52 PM, Andrei Burd <burda...@gmail.com> > wrote: > >> > >> Hi! sorry for jumping in, and at first thanks for great product. > >> > >> I got the same question = we are now migrating to Foreman ENC from ldap > >> and in LDAP we had one more parameter named ipHostNumber. I dont want > to > >> copy it, so i tried to add smart variable something like ipHostNumber = > >> facts.ipaddress > >> > > sure, just use as a matcher > > ipaddress = 'your ip' > > > > any fact or something that foreman knows about (even another param) can > be > > used as a key on the left side of the matcher. > > > > Ohad > > @ohadlevey I think the question is, can Facts be passed as the answer, > not as the the matcher. I.e given these Facts: > > hostname = foo > ip = 1.2.3.4 > > you might want to do > > Matcher: fqdn = 'foo' > Value: $ip > > and have the ENC Yaml for 'foo' display: > > classes: > bar: > quux: 1.2.3.4 > > As it stands, I don't think we can do this today - the param class > support only sends static text to the ENC, right? >

OK, we'll add that as a feature for 1.1

··· On Tue, Dec 4, 2012 at 6:31 AM, Andrei Burd wrote:

You got it right!
The point is to force Foreman to send a fact as a value.

On Monday, December 3, 2012 8:45:21 PM UTC+2, Greg Sutcliffe wrote:

On 3 December 2012 17:25, Ohad Levy ohad...@gmail.com wrote:

On Mon, Dec 3, 2012 at 6:52 PM, Andrei Burd burda...@gmail.com >> wrote:

Hi! sorry for jumping in, and at first thanks for great product.

I got the same question = we are now migrating to Foreman ENC from
ldap

and in LDAP we had one more parameter named ipHostNumber. I dont want
to

copy it, so i tried to add smart variable something like ipHostNumber
=

facts.ipaddress

sure, just use as a matcher
ipaddress = ‘your ip’

any fact or something that foreman knows about (even another param) can
be
used as a key on the left side of the matcher.

Ohad

@ohadlevey I think the question is, can Facts be passed as the answer,
not as the the matcher. I.e given these Facts:

hostname = foo
ip = 1.2.3.4

you might want to do

Matcher: fqdn = 'foo’
Value: $ip

and have the ENC Yaml for ‘foo’ display:

classes:
bar:
quux: 1.2.3.4

As it stands, I don’t think we can do this today - the param class
support only sends static text to the ENC, right?


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/foreman-users/-/p54wT0RHcJQJ.

To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

Fantastic! thanks!

··· On Tuesday, December 4, 2012 10:07:33 AM UTC+2, ohad wrote: > > OK, we'll add that as a feature for 1.1 > > > On Tue, Dec 4, 2012 at 6:31 AM, Andrei Burd <burda...@gmail.com > > wrote: > >> You got it right! >> The point is to force Foreman to send a fact as a value. >> >> On Monday, December 3, 2012 8:45:21 PM UTC+2, Greg Sutcliffe wrote: >>> >>> On 3 December 2012 17:25, Ohad Levy wrote: >>> > >>> > >>> > >>> > On Mon, Dec 3, 2012 at 6:52 PM, Andrei Burd >>> wrote: >>> >> >>> >> Hi! sorry for jumping in, and at first thanks for great product. >>> >> >>> >> I got the same question = we are now migrating to Foreman ENC from >>> ldap >>> >> and in LDAP we had one more parameter named ipHostNumber. I dont want >>> to >>> >> copy it, so i tried to add smart variable something like ipHostNumber >>> = >>> >> facts.ipaddress >>> >> >>> > sure, just use as a matcher >>> > ipaddress = 'your ip' >>> > >>> > any fact or something that foreman knows about (even another param) >>> can be >>> > used as a key on the left side of the matcher. >>> > >>> > Ohad >>> >>> @ohadlevey I think the question is, can Facts be passed as the answer, >>> not as the the matcher. I.e given these Facts: >>> >>> hostname = foo >>> ip = 1.2.3.4 >>> >>> you might want to do >>> >>> Matcher: fqdn = 'foo' >>> Value: $ip >>> >>> and have the ENC Yaml for 'foo' display: >>> >>> classes: >>> bar: >>> quux: 1.2.3.4 >>> >>> As it stands, I don't think we can do this today - the param class >>> support only sends static text to the ENC, right? >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Foreman users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/foreman-users/-/p54wT0RHcJQJ. >> >> To post to this group, send email to forema...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> foreman-user...@googlegroups.com . >> For more options, visit this group at >> http://groups.google.com/group/foreman-users?hl=en. >> > >

Great! Thanks!

··· *____________________* *Andrei Burd* *Tel: +972 (546) 46 22 36* *Skype: burdandrei*

On 4 December 2012 10:07, Ohad Levy ohadlevy@gmail.com wrote:

OK, we’ll add that as a feature for 1.1

On Tue, Dec 4, 2012 at 6:31 AM, Andrei Burd burdandrei@gmail.com wrote:

You got it right!
The point is to force Foreman to send a fact as a value.

On Monday, December 3, 2012 8:45:21 PM UTC+2, Greg Sutcliffe wrote:

On 3 December 2012 17:25, Ohad Levy ohad...@gmail.com wrote:

On Mon, Dec 3, 2012 at 6:52 PM, Andrei Burd burda...@gmail.com >>> wrote:

Hi! sorry for jumping in, and at first thanks for great product.

I got the same question = we are now migrating to Foreman ENC from
ldap

and in LDAP we had one more parameter named ipHostNumber. I dont want
to

copy it, so i tried to add smart variable something like ipHostNumber
=

facts.ipaddress

sure, just use as a matcher
ipaddress = ‘your ip’

any fact or something that foreman knows about (even another param)
can be
used as a key on the left side of the matcher.

Ohad

@ohadlevey I think the question is, can Facts be passed as the answer,
not as the the matcher. I.e given these Facts:

hostname = foo
ip = 1.2.3.4

you might want to do

Matcher: fqdn = 'foo’
Value: $ip

and have the ENC Yaml for ‘foo’ display:

classes:
bar:
quux: 1.2.3.4

As it stands, I don’t think we can do this today - the param class
support only sends static text to the ENC, right?


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/foreman-users/-/p54wT0RHcJQJ.

To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To post to this group, send email to foreman-users@googlegroups.com.
To unsubscribe from this group, send email to
foreman-users+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/foreman-users?hl=en.

+1 from me !

Daniel Gagnon

··· -- CONFIDENTIALITÉ: Ce document transmis par courriel est destiné uniquement à la personne ou à l'entité à qui il est adressé et peut contenir des renseignements confidentiels et assujettis au secret professionnel. La confidentialité et le secret professionnel demeurent malgré l'envoi de ce document à la mauvaise personne. Si vous n'êtes pas le destinataire visé ou la personne chargée de remettre ce document à son destinataire, veuillez nous en informer par téléphone et détruire ce courriel immédiatement. Toute distribution, reproduction ou autre utilisation de ce courriel par un destinataire non visé est interdite.

Hi,

I'm using Foreman 1.3.
Is it possible to force Foreman to send a fact as a value ?

Thanks.

··· Le mardi 4 décembre 2012 09:07:33 UTC+1, ohad a écrit : > > OK, we'll add that as a feature for 1.1 > > > On Tue, Dec 4, 2012 at 6:31 AM, Andrei Burd <burda...@gmail.com > > wrote: > >> You got it right! >> The point is to force Foreman to send a fact as a value. >> >> On Monday, December 3, 2012 8:45:21 PM UTC+2, Greg Sutcliffe wrote: >>> >>> On 3 December 2012 17:25, Ohad Levy wrote: >>> > >>> > >>> > >>> > On Mon, Dec 3, 2012 at 6:52 PM, Andrei Burd >>> wrote: >>> >> >>> >> Hi! sorry for jumping in, and at first thanks for great product. >>> >> >>> >> I got the same question = we are now migrating to Foreman ENC from >>> ldap >>> >> and in LDAP we had one more parameter named ipHostNumber. I dont want >>> to >>> >> copy it, so i tried to add smart variable something like ipHostNumber >>> = >>> >> facts.ipaddress >>> >> >>> > sure, just use as a matcher >>> > ipaddress = 'your ip' >>> > >>> > any fact or something that foreman knows about (even another param) >>> can be >>> > used as a key on the left side of the matcher. >>> > >>> > Ohad >>> >>> @ohadlevey I think the question is, can Facts be passed as the answer, >>> not as the the matcher. I.e given these Facts: >>> >>> hostname = foo >>> ip = 1.2.3.4 >>> >>> you might want to do >>> >>> Matcher: fqdn = 'foo' >>> Value: $ip >>> >>> and have the ENC Yaml for 'foo' display: >>> >>> classes: >>> bar: >>> quux: 1.2.3.4 >>> >>> As it stands, I don't think we can do this today - the param class >>> support only sends static text to the ENC, right? >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Foreman users" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/foreman-users/-/p54wT0RHcJQJ. >> >> To post to this group, send email to forema...@googlegroups.com >> . >> To unsubscribe from this group, send email to >> foreman-user...@googlegroups.com . >> For more options, visit this group at >> http://groups.google.com/group/foreman-users?hl=en. >> > >

> Hi,
>
> I'm using Foreman 1.3.
> Is it possible to force Foreman to send a fact as a value ?
>

so after looking,afaiu, and maybe Greg can correct me, its possible but not
trivial, you can now do:

value = <%= @host.ip %>

accessing facts actually needs to expose a bit more from foreman internals,
which is not good, and I would guess will not work with safe mode
rendering turned on.

value = <%= FactValue.joins(:fact_name).where(:host_id => @host.id, "
fact_names.name" => 'ipaddress').first.try(:value) %>

this should be really exposed into a official method such as

value = <%= fact('ipaddress') %> instead…

would you mind adding that as a feature request?

thanks,
Ohad

··· On Wed, Oct 16, 2013 at 10:45 AM, Jean-Marc Andre < jeanmarc.jim.andre@gmail.com> wrote:

Thanks.

Le mardi 4 décembre 2012 09:07:33 UTC+1, ohad a écrit :

OK, we’ll add that as a feature for 1.1

On Tue, Dec 4, 2012 at 6:31 AM, Andrei Burd burda...@gmail.com wrote:

You got it right!
The point is to force Foreman to send a fact as a value.

On Monday, December 3, 2012 8:45:21 PM UTC+2, Greg Sutcliffe wrote:

On 3 December 2012 17:25, Ohad Levy ohad...@gmail.com wrote:

On Mon, Dec 3, 2012 at 6:52 PM, Andrei Burd burda...@gmail.com >>>> wrote:

Hi! sorry for jumping in, and at first thanks for great product.

I got the same question = we are now migrating to Foreman ENC from
ldap

and in LDAP we had one more parameter named ipHostNumber. I dont
want to

copy it, so i tried to add smart variable something like
ipHostNumber =

facts.ipaddress

sure, just use as a matcher
ipaddress = ‘your ip’

any fact or something that foreman knows about (even another param)
can be
used as a key on the left side of the matcher.

Ohad

@ohadlevey I think the question is, can Facts be passed as the answer,
not as the the matcher. I.e given these Facts:

hostname = foo
ip = 1.2.3.4

you might want to do

Matcher: fqdn = 'foo’
Value: $ip

and have the ENC Yaml for ‘foo’ display:

classes:
bar:
quux: 1.2.3.4

As it stands, I don’t think we can do this today - the param class
support only sends static text to the ENC, right?


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To view this discussion on the web visit https://groups.google.com/d/**
msg/foreman-users/-/**p54wT0RHcJQJhttps://groups.google.com/d/msg/foreman-users/-/p54wT0RHcJQJ
.

To post to this group, send email to forema...@googlegroups.com**.
To unsubscribe from this group, send email to foreman-user…@**
googlegroups.com.

For more options, visit this group at http://groups.google.com/**
group/foreman-users?hl=enhttp://groups.google.com/group/foreman-users?hl=en
.


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/groups/opt_out.

Hi,

I confirm that with version 1.3 we can do:
value = <%= @host.ip %>

I've just registered on http://project.theforeman.org and I will add a new
feature request about accessing facts through an official method.

Thanks.

JM

··· 2013/10/16 Ohad Levy

On Wed, Oct 16, 2013 at 10:45 AM, Jean-Marc Andre < > jeanmarc.jim.andre@gmail.com> wrote:

Hi,

I’m using Foreman 1.3.
Is it possible to force Foreman to send a fact as a value ?

so after looking,afaiu, and maybe Greg can correct me, its possible but
not trivial, you can now do:

value = <%= @host.ip %>

accessing facts actually needs to expose a bit more from foreman
internals, which is not good, and I would guess will not work with safe
mode rendering turned on.

value = <%= FactValue.joins(:fact_name).where(:host_id => @host.id, “
fact_names.name” => ‘ipaddress’).first.try(:value) %>

this should be really exposed into a official method such as

value = <%= fact(‘ipaddress’) %> instead…

would you mind adding that as a feature request?

thanks,
Ohad

Thanks.

Le mardi 4 décembre 2012 09:07:33 UTC+1, ohad a écrit :

OK, we’ll add that as a feature for 1.1

On Tue, Dec 4, 2012 at 6:31 AM, Andrei Burd burda...@gmail.com wrote:

You got it right!
The point is to force Foreman to send a fact as a value.

On Monday, December 3, 2012 8:45:21 PM UTC+2, Greg Sutcliffe wrote:

On 3 December 2012 17:25, Ohad Levy ohad...@gmail.com wrote:

On Mon, Dec 3, 2012 at 6:52 PM, Andrei Burd burda...@gmail.com >>>>> wrote:

Hi! sorry for jumping in, and at first thanks for great product.

I got the same question = we are now migrating to Foreman ENC from
ldap

and in LDAP we had one more parameter named ipHostNumber. I dont
want to

copy it, so i tried to add smart variable something like
ipHostNumber =

facts.ipaddress

sure, just use as a matcher
ipaddress = ‘your ip’

any fact or something that foreman knows about (even another param)
can be
used as a key on the left side of the matcher.

Ohad

@ohadlevey I think the question is, can Facts be passed as the answer,
not as the the matcher. I.e given these Facts:

hostname = foo
ip = 1.2.3.4

you might want to do

Matcher: fqdn = 'foo’
Value: $ip

and have the ENC Yaml for ‘foo’ display:

classes:
bar:
quux: 1.2.3.4

As it stands, I don’t think we can do this today - the param class
support only sends static text to the ENC, right?


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To view this discussion on the web visit https://groups.google.com/d/**
msg/foreman-users/-/**p54wT0RHcJQJhttps://groups.google.com/d/msg/foreman-users/-/p54wT0RHcJQJ
.

To post to this group, send email to forema...@googlegroups.com**.
To unsubscribe from this group, send email to foreman-user…@**
googlegroups.com.

For more options, visit this group at http://groups.google.com/**
group/foreman-users?hl=enhttp://groups.google.com/group/foreman-users?hl=en
.


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/groups/opt_out.


You received this message because you are subscribed to a topic in the
Google Groups “Foreman users” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/foreman-users/c5W1l08FQm8/unsubscribe.
To unsubscribe from this group and all its topics, 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/groups/opt_out.

You should be able to use <% @host.facts_hash['ipaddress'] %> for a
slightly shorter version of what Ohad wrote :slight_smile:

Ugh, typing too fast as usual, that should be <%= … %>

··· On 16 October 2013 14:29, Greg Sutcliffe wrote:

You should be able to use <% @host.facts_hash[‘ipaddress’] %> for a
slightly shorter version of what Ohad wrote :slight_smile:

> You should be able to use <% @host.facts_hash['ipaddress'] %> for a
> slightly shorter version of what Ohad wrote :slight_smile:
>

I know, but since I was worried about performance, i wrote the long version
:wink:

··· On Wed, Oct 16, 2013 at 4:29 PM, Greg Sutcliffe wrote:


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/groups/opt_out.