Re: [Puppet Users] access "indexed" facter facts

27 views
Skip to first unread message

R.I.Pienaar

unread,
Jun 26, 2012, 9:02:32 AM6/26/12
to puppet...@googlegroups.com


----- Original Message -----
> From: "tobias" <to...@nine.ch>
> To: puppet...@googlegroups.com
> Sent: Tuesday, June 26, 2012 1:52:48 PM
> Subject: [Puppet Users] access "indexed" facter facts
>
> Hi everyone,
>
> I have a fact which looks like that: drbdconnectionstate0. You see
> the "0" at the end... Now I'd like to access this fact in a
> "dynamic" way, the "0" should be variable. I'm thinking of something
> like that: if ${drbdconnectionstate0}${drbddevice} ==
> 'Unconfigured'.
> But as you may guess, this does not work... Has anyone an idea how I
> can use such a "dynamic" facter variable?
>
> Thanks for every help!

The puppetlabs-stdlib module has a getvar() function:

$x = getvar("${drbdconnectionstate0}${drbddevice}")

tobias

unread,
Aug 7, 2012, 11:14:47 AM8/7/12
to puppet...@googlegroups.com
> I have a fact which looks like that: drbdconnectionstate0. You see
> the "0" at the end... Now I'd like to access this fact in a
> "dynamic" way, the "0" should be variable. I'm thinking of something
> like that: if ${drbdconnectionstate0}${drbddevice} ==
> 'Unconfigured'.
> But as you may guess, this does not work... Has anyone an idea how I
> can use such a "dynamic" facter variable?
>
> Thanks for every help!

The puppetlabs-stdlib module has a getvar() function:

$x = getvar("${drbdconnectionstate0}${drbddevice}")

That's exactly what I was looking for! Thanks a lot...!!
Reply all
Reply to author
Forward
0 new messages