Skip to content

Instantly share code, notes, and snippets.

@kwilczynski
Created April 22, 2011 23:27
Show Gist options
  • Select an option

  • Save kwilczynski/937936 to your computer and use it in GitHub Desktop.

Select an option

Save kwilczynski/937936 to your computer and use it in GitHub Desktop.
Accessing fact from Facter within Puppet manifest ...
# The following monstrosity ...
define partitions {
$fact = "partitions_${name}"
$result = split(inline_template("<%= scope.lookupvar(fact) %>"), ',')
notice $result
partition { $result: }
}
define partition {
notice $name
}
$available_disks = split($disks, ',')
partitions { $available_disks: }
# Will produce the following ...
kwilczynski@dev04:~/Development/Sandbox$ FACTERLIB=. puppet test.pp
notice: Scope(Partitions[hda]): hda1 hda2
notice: Scope(Partition[hda1]): hda1
notice: Scope(Partition[hda2]): hda2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment