How best to distribute yaml file for custom fact?

44 views
Skip to first unread message

Bret Wortman

unread,
Dec 12, 2013, 2:25:23 PM12/12/13
to puppet...@googlegroups.com
I have a yaml file I'd like to distribute to my systems, and it contains some identifiers which help determine where that system is (this _can_ be determined from the IP address, but it's so much nicer to use a custom fact -- we're basically assigning names to our various subnets and storing those in these yaml files where we can use them in manifests and templates).

The problem is that we are using them in templates. So when I try to distribute the file, the template fails to parse, and the whole puppet run just aborts. If it were just an error, I could deal with it. But this seems to be a show-stopper. I see that 3.4.0 will have a way to distribute these files as part of pluginsync, but I need this sooner than that (and since I'm in production, I'm hesitant to jump to a .0 release in any case).

Any bright ideas? 


Bret

Felix Frank

unread,
Dec 13, 2013, 11:17:41 AM12/13/13
to puppet...@googlegroups.com
Hi,

I can at least supply a sensible workaround: In your templates, instead
of relying on @factname being available, use

has_variable?("@factname") ? @factname : <default value here>

Untested, not sure if this works with the @varname syntax in templates.

Alternatively, you can do this in site.pp:

if ! $factname { $factname = <default> }

Depending on circumstance, this won't address your issue. As yet another
alternative, you can keep puppet from parsing the template at all when
the fact is not yet present with the same syntax.

HTH,
Felix

Bret Wortman

unread,
Dec 13, 2013, 12:35:20 PM12/13/13
to puppet...@googlegroups.com
That seems to do the trick (I went with the site.pp addition). Thanks for your help!

--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/zMDPDGg9Nbw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/52AB3325.5050200%40alumni.tu-berlin.de.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages