Peter Meier
2013-Mar-19 08:58 UTC
[Puppet Users] Passing variables from one template to another "included" template
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi all, I have the following basic requirement to pass variables from one template to another "included" one: #some_template.erb <%- [:foo, :bar].each do |state| %> <%= scope.function_template(''some/other_template.erb'') %> <%- end %> # some/other_template.erb <%- if state == :foo %> write something <%- end %> However, this does not work like that and in #6492 [1] we came up with a workaround: #some_template.erb <%- [:foo, :bar].each do |state| scope.unsetvar(''state'') scope.setvar(''state'',state) %> <%= scope.function_template(''some/other_template.erb'') %> <%- end %> This worked until 3.x, but in 3.x unsetvar was removed (it was already marked as used only for testing in < 3.x codebase). To get a proper solution for that I opened #6592 [2]. So what options do I have in 3.x to address my requirements? Something that would also work on < 3.x would be nice. Thanks ~pete [1] http://projects.puppetlabs.com/issues/6492 [2] http://projects.puppetlabs.com/issues/6592 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlFIKLAACgkQbwltcAfKi3+qfQCgiqrqWHrAQFXe2eBjsT0isbFQ cHAAni3fL1WeusPzBh0gcikLeD09vU/Q =4ry6 -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
Peter Meier
2013-Mar-20 20:57 UTC
Re: [Puppet Users] Passing variables from one template to another "included" template
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1> So what options do I have in 3.x to address my requirements? > Something that would also work on < 3.x would be nice.I figured out that I can achieve that with an extended templatewrapper: http://forge.puppetlabs.com/duritong/templatewlv ~pete -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlFKIrQACgkQbwltcAfKi38HlQCcC/QSyb8bYs2EoOzSU+0bNP01 pJAAn1w0L9nUfQQjqaXyBa3uk5TMjWbM =9xo1 -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users+unsubscribe@googlegroups.com. To post to this group, send email to puppet-users@googlegroups.com. Visit this group at http://groups.google.com/group/puppet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.