rendered paste body# Why can't I use $name in a default for a parameter?
define myexec ( $a = $name ) {
exec { $name :
cwd => "/tmp"
, path => "/bin"
, command => "/bin/echo ${name} ${a}"
}
}
myexec{ [ "a", "b", "c"] : }
When executed:
puppet --debug ./TestNameInDefine.pp
debug: Creating default schedules
debug: Failed to load library 'shadow' for feature 'libshadow'
debug: //Myexec[b]/Exec[b]: Changing returns
debug: //Myexec[b]/Exec[b]: 1 change(s)
debug: //Myexec[b]/Exec[b]: Executing '/bin/echo b '
debug: Executing '/bin/echo b '
notice: //Myexec[b]/Exec[b]/returns: executed successfully
debug: //Myexec[c]/Exec[c]: Changing returns
debug: //Myexec[c]/Exec[c]: 1 change(s)
debug: //Myexec[c]/Exec[c]: Executing '/bin/echo c '
debug: Executing '/bin/echo c '
notice: //Myexec[c]/Exec[c]/returns: executed successfully
debug: //Myexec[a]/Exec[a]: Changing returns
debug: //Myexec[a]/Exec[a]: 1 change(s)
debug: //Myexec[a]/Exec[a]: Executing '/bin/echo a '
debug: Executing '/bin/echo a '
notice: //Myexec[a]/Exec[a]/returns: executed successfully
debug: Finishing transaction -609251768 with 3 changes