Smart Variables in Config Templates

Hi all!

Currently I'm rather happily toying around with Foreman for replacing our
aging Puppet infrastructure and propel it into this decennium :slight_smile:

I have a quick question though which I've been searching all day for
without success; how can I access the Smart Variables (and all variables
set for Puppet classes) from within the Provisioning Templates for a Host?

Here's the basic idea: The Host, Organization & Location parameters can
only be flat uncontrollable strings; AFAICT these also can't be used as
anything else in the Smart Variables parts (or maybe with some strange
.split().to_yaml hack or something, but this all feels kind of brittle).
On the other hand, the Smart Variable stuff is where all the magic is
happening, and for us, it should contain every bit of flexibility we could
ever wish for.
<BUT> these variables don't seem accessible in the Provisioning Templates.

So the only thing I can think of right now is to set BOTH a Location
parameter (and parse through that in the Provisioning Template with
.split() ) AND the Smart Var array (so Puppet can set/keep the setting
right) or set the Smart Var array based on an uncontrollable string (if
that's even possible). That doesn't feel right :slight_smile:

Anyone? Thanks in advance!

Greetz

Ronald

Sorry for hijacking the thread but got a similar problem/request.

Spend the better part yesterday searching and found a couple of bits and
pieces but not enough to get things going.
I would like to know what can be done in the Smart Variables, found a
feature request and it seems that has been implemented (sorry lost my
paste buffer with that in it). I know I can do things like
<%=@host.params['cname'] %> where cname is a Global parameter. But I
would like to know if its possible to access for example puppet
variables. Example being the puppet-labs mysql module which has a $users
hash that I would like to be a bit more dynamic.

Joop

路路路 On 3-9-2014 17:31, Ronald van Zantvoort wrote: > Hi all! > > Currently I'm rather happily toying around with Foreman for replacing > our aging Puppet infrastructure and propel it into this decennium :) > > I have a quick question though which I've been searching all day for > without success; how can I access the Smart Variables (and all > variables set for Puppet classes) from within the Provisioning > Templates for a Host? >

Hi Joop!

I knew I couldn't be the first one to think of this :D! It seems so
assymetrically illogical not to have that info at your fingertips in the
Templates :slight_smile:

Anyway, it took more than a little digging & wading through source, but I
figured a solution (ducks for cover)

When you look at the dashboard in the BUI there's a button for a YAML with
all of the hostinfo in it.
Turns out that is (jeeuj for good programming practices) a function of what
is known as @host.

So, to access the same information array-wise (using that YAML as
handy-dandy reference), we can use something like <%=
@host.info['classes']['ntp']['servers'][0] %> for the first Smart-Variable
set server
I'm guessing safe rendering should be off for this one to work.

Greetz

Ronald

路路路 On Thursday, 4 September 2014 09:23:37 UTC+2, jvandewege wrote: > > On 3-9-2014 17:31, Ronald van Zantvoort wrote: > > Hi all! > > > > Currently I'm rather happily toying around with Foreman for replacing > > our aging Puppet infrastructure and propel it into this decennium :) > > > > I have a quick question though which I've been searching all day for > > without success; how can I access the Smart Variables (and all > > variables set for Puppet classes) from within the Provisioning > > Templates for a Host? > > > Sorry for hijacking the thread but got a similar problem/request. > > Spend the better part yesterday searching and found a couple of bits and > pieces but not enough to get things going. > I would like to know what can be done in the Smart Variables, found a > feature request and it seems that has been implemented (sorry lost my > paste buffer with that in it). I know I can do things like > <%=@host.params['cname'] %> where cname is a Global parameter. But I > would like to know if its possible to access for example puppet > variables. Example being the puppet-labs mysql module which has a $users > hash that I would like to be a bit more dynamic. > > Joop > >