I have a very simple use for puppet
; I create and delete students from a test server. I would like to store some configuration variables in another file and then just do a simple: include 'variables.pp'
at the top of my manifest file. Is there a simple way to do this? I have consulted:
https://docs.puppet.com/puppet/latest/reference/lang_classes.html#using-include https://puppet.com/blog/problem-separating-data-from-puppet-code
None of which give a simple solution. If I can only use the solutions above, I'll just hardcode it in my manifest.
Puppet 3 has an import
statement that should serve your purpose. It is deprecated (and removed from Puppet 4), but it will do the job for you in Puppet 3:
variables.pp
# top-scope variables:
$var1 = 'foo'
$var2 = 'bar'
main.pp
import 'variables.pp'
# demo
notify { "var1 = ${var1}; var2 = ${var2}": }
Note that Puppet's import
does not perform text interpolation; it is more like Python's import
, making complete declarations from another manifest visible in the importing manifest.