Skip to content

Instantly share code, notes, and snippets.

@nrvale0
Last active Aug 29, 2015
Embed
What would you like to do?
scope.lookupvar() example
# frank/manifests/init.pp
# -----------------------
class frank ( $foo ='bar' ) {
include frank::bob
class { 'frank::joe': foo => $foo }
}
class frank::bob {
file { '/var/lib/bob':ensure => "directory"}
}
class frank::joe ($foo='bob') {
file { '/var/lib/bob/${foo}.txt':
content => template("${module_name}/file.erb"),
owner => "frank",
}
}
# frank/templates/file.erb
# ------------------------
$frank:foo is *not* available by walking the scope because the ERB templating engine does
not understand Puppet namespace syntax:
$frank::foo value is <%= @frank::foo %>
but we can call the scope.lookupvar() function which *does* understand Puppet namespace syntax:
$frank::foo valud is <%= scope.lookupvar('$frank::foo') %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment