Follow up to feature request for 1.1

Greetings,
I was searching the group for a solution to a problem I have, and found a
seemingly related topic from about 7 months ago that Ohad mentioned would
be put on the features pile for v1.1. Thread subject is : "Use facts in
smart-variable values"

I'm wondering first of all if this has been implemented. I'm running
Foreman 1.2 and have been working to build up a Host Group to define my
provisioning servers (where I run foreman-proxy, dhcpd, tftp, etc.) for
secure subnets. I seem to be encountering a scenario where the
parameterized classes I have got deployed don't play well with setting a
foreman parameter at the group level like:

dhcpd_source = "puppet:///modules/provisiongrp/dhcpd/dhcpd.conf.${hostname}"

I'm expecting the config file source to expand to pick up the appropriate
config file, but the node's puppet run produces an error like:

Error: /File[dhcpd.conf]: Could not evaluate: Could not retrieve
information from environment ops source(s)
puppet:///modules/provisiongrp/dhcpd/dhcpd.conf.${hostname}

It's entirely possible (and perhaps probable) that I've misunderstood the
feature request noted in the thread I mentioned. But I'm still struggling
to understand why the 'source' field of a file resource can not follow the
array pattern (e.g. [ "file.conf.$hostname", "file.conf.$operatingsystem",
"file.conf" ] ). I'm not sure if this issue is complicated the module
itself, but the module uses a params_lookup function. In Foreman, all of
the modules Smart Class Parameters are detected as String Types with the
value set as the params_lookup("<param name>").

Is this just not possible to do at all with Foreman, or does the module
I've selected have compatibility problems with Foreman?

Thanks for your thoughts.

This isn't currently possible in Foreman - all parameter values are static.
I have an open Pull Request allowing the use of ERB in parameter values (so
<%= @host.subnet %> or <%= @host.facts_hash['ipaddress_eth0'] %> which you
can find at https://github.com/theforeman/foreman/pull/435. I do plan to
rebase it soon for latest develop (which has moved things around a bit) but
as of right now, I think it will apply to 1.2 OK. Hope it's useful :slight_smile:

Greg

··· On 15 July 2013 20:27, Sean Alderman wrote:

Greetings,
I was searching the group for a solution to a problem I have, and found
a seemingly related topic from about 7 months ago that Ohad mentioned would
be put on the features pile for v1.1. Thread subject is : “Use facts in
smart-variable values”