set fact based on top scope variable

72 views
Skip to first unread message

Brandon Metcalf

unread,
Apr 17, 2015, 12:02:09 PM4/17/15
to puppet...@googlegroups.com
Is it possible to reference a top scope variable passed in from an ENC and set a fact based on that?  That is,

parameters:
  var: value

I know it's the other way around that top scope variables are set from facts, but just trying to figure out the best way to do this other that writing out a script to set an external fact on the next puppet run.

Thanks.

Christopher Wood

unread,
Apr 17, 2015, 1:14:00 PM4/17/15
to puppet...@googlegroups.com
I did just that, used a template to populate some external facts:

[root@host123cluster123 ~]# cat /etc/facter/facts.d/inventory.txt
cluster=123
servertype=typename
stype=typename
datacenter=dcname
owner=groupname

[puppet exp] $ cat inventory.erb
<%# these will be blank if the variable does not exist -%>
<%# next 4 are set in cobbler's kickstart metadata -%>
cluster=<%= @cluster %>
servertype=<%= @stype %>
stype=<%= @stype %>
datacenter=<%= @datacenter %>
owner=<%= @owner %>

These end up in puppetdb and are available to mcollective when the usual collections happen. I haven't noticed any adverse effects from doing it this way.
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [1]puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]https://groups.google.com/d/msgid/puppet-users/CAHSDT%3DSMQGQbGDJs-MXABgdwvHgPf-yoOyE4xSZnjsG9gXw7HA%40mail.gmail.com.
> For more options, visit [3]https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:puppet-users...@googlegroups.com
> 2. https://groups.google.com/d/msgid/puppet-users/CAHSDT%3DSMQGQbGDJs-MXABgdwvHgPf-yoOyE4xSZnjsG9gXw7HA%40mail.gmail.com?utm_medium=email&utm_source=footer
> 3. https://groups.google.com/d/optout
Reply all
Reply to author
Forward
0 new messages