Skip to content

Instantly share code, notes, and snippets.

@b4ldr
Created November 17, 2022 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save b4ldr/3cfe36803658ffb872478b31ab44ab1c to your computer and use it in GitHub Desktop.
Save b4ldr/3cfe36803658ffb872478b31ab44ab1c to your computer and use it in GitHub Desktop.
class classtest1 ($classfoobar) {
inline_template('<% @classfoobar.each {|i| i.upcase! } %>')
notice($classfoobar)
}
class classtest2 ($classfoobar) {
inline_template('<% @classfoobar.each {|i| i.upcase! } %>')
notice($classfoobar)
}
class classtest3 ($classfoobar = ['foo', 'bar']) {
inline_template('<% @classfoobar.each {|i| i.upcase! } %>')
notice($classfoobar)
}
define test ($classfoobar) {
inline_template('<% @classfoobar.each {|i| i.upcase! } %>')
notice($classfoobar)
}
$foo = "foobar"
inline_template('<% @foo.upcase! %>')
notice($foo)
$bar = [$foo]
notice($bar)
inline_template('<% @bar.each {|i| i.downcase! } %>')
notice($bar)
inline_template('<% @bar << "stuff" %>')
notice($bar)
$foobar = ['foo', 'bar']
class{'classtest1': classfoobar => ['foo', 'bar'] }
class{'classtest2': classfoobar => $foobar }
include classtest3
# The following fail with: "can't modify frozen String"
test{'test1': classfoobar => $foobar }
inline_template('<% @foobar.each {|i| i.upcase! } %>')
notice($foobar)
@b4ldr
Copy link
Author

b4ldr commented Nov 17, 2022

$ $ puppet apply ~/git/puppet_test/mutable.pp                               
Notice: Scope(Class[main]): FOOBAR
Notice: Scope(Class[main]): [FOOBAR]
Notice: Scope(Class[main]): [foobar]
Notice: Scope(Class[main]): [foobar, stuff]
Notice: Scope(Class[Classtest1]): [FOO, BAR]
Notice: Scope(Class[Classtest2]): [FOO, BAR]
Notice: Scope(Class[Classtest3]): [FOO, BAR]
Error: Evaluation Error: Error while evaluating a Function Call, Failed to parse inline template: can't modify frozen String: "foo" (file: /home/jbond/git/puppet_test/mutable.pp, line: 38, column: 1) on node storage.home.arpa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment