Re: [Puppet Users] variable scoping and erb templates

2016-08-16 Thread R.I.Pienaar
- Original Message - > From: "Matt Zagrabelny" <mzagr...@d.umn.edu> > To: "puppet-users" <puppet-users@googlegroups.com> > Sent: Tuesday, 16 August, 2016 15:07:28 > Subject: Re: [Puppet Users] variable scoping and erb templates > On Tue, Au

Re: [Puppet Users] variable scoping and erb templates

2016-08-16 Thread Matt Zagrabelny
On Tue, Aug 16, 2016 at 8:04 AM, jcbollinger wrote: >> >> On Tue, Aug 16, 2016 at 1:31 AM, Lowe Schmidt wrote: >> > What version of Puppet are you running? >> >> Debian Jessie: >> >> 3.7.2-4 >> > > > That looks like bug PUP-1220. Note that

Re: [Puppet Users] variable scoping and erb templates

2016-08-16 Thread jcbollinger
On Tuesday, August 16, 2016 at 7:06:28 AM UTC-5, Matt Zagrabelny wrote: > > Hi Lowe, > > On Tue, Aug 16, 2016 at 1:31 AM, Lowe Schmidt > wrote: > > What version of Puppet are you running? > > Debian Jessie: > > 3.7.2-4 > > That looks like bug PUP-1220

Re: [Puppet Users] variable scoping and erb templates

2016-08-16 Thread Matt Zagrabelny
Hi Lowe, On Tue, Aug 16, 2016 at 1:31 AM, Lowe Schmidt wrote: > What version of Puppet are you running? Debian Jessie: 3.7.2-4 -m > -- > Lowe Schmidt | +46 723 867 157 > > On 15 August 2016 at 20:48, Matt Zagrabelny wrote: >> >> Greetings! >> >> I am

Re: [Puppet Users] variable scoping and erb templates

2016-08-16 Thread Lowe Schmidt
What version of Puppet are you running? -- Lowe Schmidt | +46 723 867 157 On 15 August 2016 at 20:48, Matt Zagrabelny wrote: > Greetings! > > I am hitting a curious question and couldn't find an answer. > > I can access variables from other classes when using an erb

[Puppet Users] variable scoping and erb templates

2016-08-15 Thread Matt Zagrabelny
Greetings! I am hitting a curious question and couldn't find an answer. I can access variables from other classes when using an erb template. Here is my minimal example: # puppet apply variable_scope_test.pp Notice: Compiled catalog for puppet.example.com in environment production in 0.12

[Puppet Users] variable scoping and templates

2014-04-30 Thread drs
I am new to puppet and am trying to figure out variable scoping. I have a test module that I am using for this and it looks like this: manifiests/init.pp: class test { include test::params file { 'testfile' : path = /tmp/testfile, content = template(test/testfile.erb), } }

Re: [Puppet Users] variable scoping and templates

2014-04-30 Thread Matthew Burgess
We just ran into this too recently. From my investigation it looks like the syntax you quote above is for referencing Hiera values in Puppet manifests. For erb templates we ended up using scope.function_hiera () although I wonder now whether a scope.lookupvar () call would a) be better and b) be

Re: [Puppet Users] variable scoping and templates

2014-04-30 Thread jcbollinger
On Wednesday, April 30, 2014 2:43:07 PM UTC-5, Matthew Burgess wrote: We just ran into this too recently. From my investigation it looks like the syntax you quote above is for referencing Hiera values in Puppet manifests. Nope, absolutely not. Templates have visibility into hiera only

[Puppet Users] Variable scoping question

2014-01-17 Thread Bret Wortman
I'm trying to improve my code reuse a bit, and I have some templates that all start with a common case statement to determine a local proxy (I'm simplifying the file slightly for our discussion here): file: proxy.erb % proxy = case @site when a then proxya when b then proxyb when c

Re: [Puppet Users] variable scoping?

2012-08-15 Thread Zachary Stern
My point was that I don't use and won't be using multiple puppet masters. Also, at my current level of puppet knowledge, Nan's code is basically meaningless to me :( On Wed, Aug 15, 2012 at 9:51 AM, jcbollinger john.bollin...@stjude.orgwrote: To use multiple Puppet masters for the same site

[Puppet Users] Variable scoping question

2012-08-14 Thread Davíð Steinn Geirsson
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi all, I have a configuration similar to the following (the puppet version is 2.6.16): node basenode { $ldapenvironment = office } node mynode inherits basenode { include ldap } class ldap { file {

Re: [Puppet Users] variable scoping?

2012-08-14 Thread Zachary Alex Stern
Sorry typo: class puppet ( $server = $puppet::params::server ) inherits puppet::params { FWIW, this works: class puppet::config { include puppet::params $puppetserver=$puppet::params::puppetserver $runinterval=$puppet::params::runinterval file { '/etc/puppet/puppet.conf':

Re: [Puppet Users] variable scoping?

2012-08-14 Thread Chad Huneycutt
On Tue, Aug 14, 2012 at 11:56 AM, Zachary Alex Stern z...@enternewmedia.com wrote: FWIW, this works: class puppet::config { include puppet::params $puppetserver=$puppet::params::puppetserver $runinterval=$puppet::params::runinterval file { '/etc/puppet/puppet.conf': ensure

Re: [Puppet Users] variable scoping?

2012-08-14 Thread Zachary Stern
That's a fair point, but not applicable to my use-case (multiple puppet servers). However, at some point in the near future, I'll be using hiera, and that will be moot. On Tue, Aug 14, 2012 at 1:44 PM, Chad Huneycutt chad.huneyc...@gmail.comwrote: On Tue, Aug 14, 2012 at 11:56 AM, Zachary Alex

Re: [Puppet Users] variable scoping?

2012-08-13 Thread Zachary Stern
Ok, that's helpful, however: On Sun, Aug 12, 2012 at 8:43 AM, Eric Shamow e...@puppetlabs.com wrote: An example: suppose is this module you say $puppetmaster = myserver.local and in another module, you want to only run on a puppet master and so say $puppetmaster = true. When Puppet assembles

Re: [Puppet Users] variable scoping?

2012-08-13 Thread Nan Liu
On Mon, Aug 13, 2012 at 8:31 AM, Zachary Stern z...@enternewmedia.com wrote: Ok, that's helpful, however: On Sun, Aug 12, 2012 at 8:43 AM, Eric Shamow e...@puppetlabs.com wrote: An example: suppose is this module you say $puppetmaster = myserver.local and in another module, you want to

Re: [Puppet Users] variable scoping?

2012-08-13 Thread Zachary Stern
class puppet ( $server = $puppet::params::server ) include puppet::params { ... } If I'm already specifying scope, e.g. $server = $puppet::params::server, why do I also need the include? -- zachary alex stern I systems architect | ceo - enter: narnia o: 212.731.2033 | f:

Re: [Puppet Users] variable scoping?

2012-08-13 Thread Nan Liu
On Mon, Aug 13, 2012 at 9:37 AM, Zachary Stern z...@enternewmedia.com wrote: class puppet ( $server = $puppet::params::server ) include puppet::params { ... } If I'm already specifying scope, e.g. $server = $puppet::params::server, why do I also need the include? Sorry typo: class

Re: [Puppet Users] variable scoping?

2012-08-13 Thread Zachary Stern
On Mon, Aug 13, 2012 at 12:42 PM, Nan Liu n...@puppetlabs.com wrote: class puppet ( $server = $puppet::params::server ) inherits puppet::params { Still missing something here - why do I need inherits, or ANY statement at all, other than the $server = $puppet::params::server.

Re: [Puppet Users] variable scoping?

2012-08-13 Thread Nan Liu
On Mon, Aug 13, 2012 at 9:45 AM, Zachary Stern z...@enternewmedia.com wrote: On Mon, Aug 13, 2012 at 12:42 PM, Nan Liu n...@puppetlabs.com wrote: class puppet ( $server = $puppet::params::server ) inherits puppet::params { Still missing something here - why do I need inherits, or ANY

Re: [Puppet Users] variable scoping?

2012-08-12 Thread Zachary Alex Stern
So, your explanation makes sense to me - but that doesn't exactly explain to me why the include statement isn't enough. E.g. when I'm including the puppet::params class in the puppet::config class, what affect is it having at all, if not setting things like the variables included in the

Re: [Puppet Users] variable scoping?

2012-08-12 Thread Eric Shamow
First off, it's important to distinguish import from include. They feel like similar concepts but they're not - import goes and physically loads a file. Include says ensure that this class is part of this host's resource graph. It's important not to think of Puppet in procedural, top-down

Re: [Puppet Users] variable scoping?

2012-08-12 Thread devzero2000
On Sun, Aug 12, 2012 at 2:43 PM, Eric Shamow e...@puppetlabs.com wrote: First off, it's important to distinguish import from include. They feel like similar concepts but they're not - import goes and physically loads a file. Include says ensure that this class is part of this host's resource

[Puppet Users] variable scoping?

2012-08-11 Thread Zachary Stern
I'm having a really hard time grasping how variables are scoped in puppet (not really much of a programmer). I've got a manifest that looks like this: ### class puppet::config { include puppet::params file { '/etc/puppet/puppet.conf': ensure = present, content =

Re: [Puppet Users] variable scoping?

2012-08-11 Thread Eric Shamow
The best reference to explain how variable scoping works in Puppet is this one - http://docs.puppetlabs.com/guides/scope_and_puppet.html Scoping has changed with 2.7, so you may find some confusing references online that follow the pre-2.7 rules. In general the 2.7 changes are designed to

Re: [Puppet Users] variable scoping?

2012-08-11 Thread Eric Shamow
Sorry, that should be $puppetserver = $puppet::params::puppetserver -Eric -- Eric Shamow Professional Services http://puppetlabs.com/ ©631.871.6441 Join us for PuppetConf 2012 at the Mission Bay Convention Center in San Francisco, California on September 27th and 28th --

Re: [Puppet Users] variable scoping?

2012-08-11 Thread Zachary Alex Stern
Sorry, that should be $puppetserver = $puppet::params::puppetserver -Eric Seems like at that point I may as well just do this inside the template: %= scope.lookupvar('puppet::params::puppetserver') % -- You received this message because you are subscribed to the Google Groups

Re: [Puppet Users] variable scoping?

2012-08-11 Thread Zachary Alex Stern
Also, fwiw, I've read that document on scoping beginning to end several times. Doesn't mean much to me I'm afraid - pretty new to all this. On Saturday, August 11, 2012 10:36:48 PM UTC-4, Eric Shamow wrote: The best reference to explain how variable scoping works in Puppet is this one -

Re: [Puppet Users] variable scoping?

2012-08-11 Thread Douglas Garstang
I feel your pain. On Sat, Aug 11, 2012 at 10:24 PM, Zachary Alex Stern z...@enternewmedia.com wrote: Also, fwiw, I've read that document on scoping beginning to end several times. Doesn't mean much to me I'm afraid - pretty new to all this. On Saturday, August 11, 2012 10:36:48 PM UTC-4,

Re: [Puppet Users] variable scoping?

2012-08-11 Thread Eric Shamow
Zachary, Is there a particular section of the scoping doc I can help you understand? -Eric -- Eric Shamow Professional Services http://puppetlabs.com/ ©631.871.6441 Join us for PuppetConf 2012 at the Mission Bay Convention Center in San Francisco, California on September 27th and 28th --

[Puppet Users] Variable scoping / best practice

2011-05-12 Thread Luke Baker
Hey there, I have the following class that defines an array: class iptables::hyperion { system_ips [ 'ip', 'ip', 'ip', ... ] } To use this variable in a template, I'm setting it to a 'local' variable in the node definition: node 'mynode' inherits basenode { include

[Puppet Users] variable scoping problems with import

2010-08-05 Thread Alan Barrett
I don't know what I m doing wrong, but I ca't get this to work. I want some nodes to explicitly set a variable $x, and other nodes to get a default value. I want to calculate another variable $y in a different way depending on whether or not $x is set. ## site.pp: node default { $x = x set

Re: [Puppet Users] Variable Scoping: What do you want?

2010-07-09 Thread David Schmitt
On 7/8/2010 10:33 PM, Joe McDonagh wrote: On 07/02/2010 04:45 AM, David Schmitt wrote: On 6/30/2010 1:47 AM, Joe McDonagh wrote: Also, it would be *huge* to be able to append to vars. Right now I open fw ports via a variable in the node def like: $open_tcp_ports = 22,443 If I could always

Re: [Puppet Users] Variable Scoping: What do you want?

2010-07-08 Thread Joe McDonagh
On 07/02/2010 04:45 AM, David Schmitt wrote: On 6/30/2010 1:47 AM, Joe McDonagh wrote: Also, it would be *huge* to be able to append to vars. Right now I open fw ports via a variable in the node def like: $open_tcp_ports = 22,443 If I could always open 22 in the node def, but += inside

Re: [Puppet Users] Variable Scoping: What do you want?

2010-07-05 Thread David Schmitt
On 7/5/2010 12:04 AM, Matt wrote: On 2 July 2010 09:50, David Schmittda...@dasz.at wrote: On 6/30/2010 10:57 AM, Matt wrote: On 29 June 2010 17:22, Luke Kaniesl...@puppetlabs.comwrote: Hi all, Given the number of threads on variable scoping recently, it's pretty clear we need to

Re: [Puppet Users] Variable Scoping: What do you want?

2010-07-05 Thread Matt
On 5 July 2010 09:15, David Schmitt da...@dasz.at wrote: On 7/5/2010 12:04 AM, Matt wrote: On 2 July 2010 09:50, David Schmittda...@dasz.at  wrote: On 6/30/2010 10:57 AM, Matt wrote: On 29 June 2010 17:22, Luke Kaniesl...@puppetlabs.com    wrote: Hi all, Given the number of threads on

Re: [Puppet Users] Variable Scoping: What do you want?

2010-07-04 Thread Matt
On 2 July 2010 09:50, David Schmitt da...@dasz.at wrote: On 6/30/2010 10:57 AM, Matt wrote: On 29 June 2010 17:22, Luke Kaniesl...@puppetlabs.com  wrote: Hi all, Given the number of threads on variable scoping recently, it's pretty clear we need to change how it works.  Markus has a lot

Re: [Puppet Users] Variable Scoping: What do you want?

2010-07-02 Thread David Schmitt
On 6/30/2010 1:47 AM, Joe McDonagh wrote: Also, it would be *huge* to be able to append to vars. Right now I open fw ports via a variable in the node def like: $open_tcp_ports = 22,443 If I could always open 22 in the node def, but += inside classes for httpd, nfs, etc. things would be nice.

Re: [Puppet Users] Variable Scoping: What do you want?

2010-07-02 Thread David Schmitt
On 6/30/2010 10:57 AM, Matt wrote: On 29 June 2010 17:22, Luke Kaniesl...@puppetlabs.com wrote: Hi all, Given the number of threads on variable scoping recently, it's pretty clear we need to change how it works. Markus has a lot of this redone in his futures branch, and I'm asking him to

Re: [Puppet Users] Variable Scoping: What do you want?

2010-07-02 Thread David Schmitt
On 6/30/2010 5:07 PM, Patrick Mohr wrote: By the way, ignoring the technical aspect, how do you think defined should work in this case? In this case, what aleart should be printed, or what error should be printed? This is a rather contrived example, but I'm not really sure what puppet should

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread Matt
On 29 June 2010 17:22, Luke Kanies l...@puppetlabs.com wrote: Hi all, Given the number of threads on variable scoping recently, it's pretty clear we need to change how it works.  Markus has a lot of this redone in his futures branch, and I'm asking him to fully describe what the results will

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread R.I.Pienaar
- Luke Kanies l...@puppetlabs.com wrote: Hi all, Given the number of threads on variable scoping recently, it's pretty clear we need to change how it works. Markus has a lot of this redone in his futures branch, and I'm asking him to fully describe what the results will be when

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread Trevor Vaughan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 If possible, I would like to see a special variables derivative of class that allow for multiple inheritance so that you could pull variables from multiple top-level classes and override them at a single point. This would prevent the multiple tree to

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread R.I.Pienaar
- Trevor Vaughan tvaug...@onyxpoint.com wrote: Also, I'm not entirely convinced that variables can't be overridden. I understand that the final compilation is order independent, but I believe that the initial run is file order dependent. I.e. if you don't declare an 'include' before an

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread Trevor Vaughan
Fair enough. If it is a bug, then consider that suggestion null and void. Did you note that defined() should not blow up if you don't have the class on your system at all? Sorry, running in text only mode today :-/. Thanks, Trevor On 6/30/10, R.I.Pienaar r...@devco.net wrote: - Trevor

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread R.I.Pienaar
'lo - Trevor Vaughan tvaug...@onyxpoint.com wrote: Did you note that defined() should not blow up if you don't have the class on your system at all? hehe never seen this behavior but did just test, I'd say that another bug worth filing separately Sorry, running in text only mode

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread Patrick Mohr
On Jun 30, 2010, at 3:09 AM, R.I.Pienaar wrote: - Trevor Vaughan tvaug...@onyxpoint.com wrote: Also, I'm not entirely convinced that variables can't be overridden. I understand that the final compilation is order independent, but I believe that the initial run is file order

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread R.I.Pienaar
hey - Patrick Mohr kc7...@gmail.com wrote: On Jun 30, 2010, at 3:09 AM, R.I.Pienaar wrote: - Trevor Vaughan tvaug...@onyxpoint.com wrote: Also, I'm not entirely convinced that variables can't be overridden. I understand that the final compilation is order independent, but

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread Patrick Mohr
On Jun 30, 2010, at 8:33 AM, R.I.Pienaar wrote: hey - Patrick Mohr kc7...@gmail.com wrote: On Jun 30, 2010, at 3:09 AM, R.I.Pienaar wrote: - Trevor Vaughan tvaug...@onyxpoint.com wrote: Also, I'm not entirely convinced that variables can't be overridden. I understand

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-30 Thread Trevor Vaughan
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 FYI, it's this bug: http://projects.reductivelabs.com/issues/3490 That's definitely going to need to get fixed before the module forge is really going to take off. Trevor On 06/30/2010 10:05 AM, R.I.Pienaar wrote: 'lo - Trevor Vaughan

[Puppet Users] Variable Scoping: What do you want?

2010-06-29 Thread Luke Kanies
Hi all, Given the number of threads on variable scoping recently, it's pretty clear we need to change how it works. Markus has a lot of this redone in his futures branch, and I'm asking him to fully describe what the results will be when that's merged, but my guess is that there are

Re: [Puppet Users] Variable Scoping: What do you want?

2010-06-29 Thread Gabriel Filion
On 2010-06-29 19:47, Joe McDonagh wrote: On 06/29/2010 12:22 PM, Luke Kanies wrote: Hi all, Given the number of threads on variable scoping recently, it's pretty clear we need to change how it works. Markus has a lot of this redone in his futures branch, and I'm asking him to fully describe

Re: [Puppet Users] Variable Scoping = Root Canal

2010-06-28 Thread Douglas Garstang
On Mon, Jun 28, 2010 at 4:07 AM, Alan Barrett a...@cequrux.com wrote: On Sun, 27 Jun 2010, Douglas Garstang wrote: node 'node1.fr.xxx.com' {   include facility::sjc   include ldap::client } In this example, variables defined in facility::sjc are not visible in ldap::client (in this case,

Re: [Puppet Users] Variable Scoping = Root Canal

2010-06-28 Thread Alan Barrett
On Mon, 28 Jun 2010, Douglas Garstang wrote: node 'node1.fr.xxx.com' { $facility_name = sjc include ldap::client Not gonna work. It's pointless to define the facility at the node level. You have to set the facility name somewhere. If not at the node level, then where?

Re: [Puppet Users] Variable Scoping = Root Canal

2010-06-28 Thread Trevor Hemsley
This actually looks like a prime candidate for a custom written fact so that you don't have to faff about like this all over the place. On 28/06/2010 17:28, Alan Barrett wrote: On Mon, 28 Jun 2010, Douglas Garstang wrote: node 'node1.fr.xxx.com' { $facility_name = sjc

[Puppet Users] variable scoping over and over

2010-06-28 Thread Antony Mayi
this topic is currently being massively discussed so I just would like to share my pain also. my intention was to have an array of node's roles and each included role class would just record into the array its role identificator. then I could write simple function has_role and then write

Re: [Puppet Users] variable scoping over and over

2010-06-28 Thread Digant C Kasundra
Wow, this really makes Puppet look like a programming language, which it isn't. Have you considered creating classes for each of the roles and then classes that include those roles and then assigning one of those classes to each node? We have hundreds of combinations here but that's how we do

Re: [Puppet Users] variable scoping over and over

2010-06-28 Thread Dan Bode
On Mon, Jun 28, 2010 at 10:22 AM, Antony Mayi antonym...@yahoo.com wrote: this topic is currently being massively discussed so I just would like to share my pain also. my intention was to have an array of node's roles and each included role class would just record into the array its role

Re: [Puppet Users] Variable Scoping = Root Canal

2010-06-28 Thread Douglas Garstang
On Mon, Jun 28, 2010 at 9:28 AM, Alan Barrett a...@cequrux.com wrote: On Mon, 28 Jun 2010, Douglas Garstang wrote:    node 'node1.fr.xxx.com' {        $facility_name = sjc        include ldap::client Not gonna work. It's pointless to define the facility at the node level. You have to

[Puppet Users] Variable Scoping = Root Canal

2010-06-27 Thread Douglas Garstang
I've been struggling with puppet variable scope all day, well, for several months actually. I think I have pretty simple requirements. For any given node, I want to be able to set a series of variables and include a set of classes, based on three different aspects of a node, being physical

Re: [Puppet Users] Variable Scoping = Root Canal

2010-06-27 Thread Steve Neuharth
I think you could do: node 'node1.fr.xxx.com' { include facility::sjc $my_ldap_server = $facility::sjc::ldap_server include ldap::client } On Sun, Jun 27, 2010 at 2:02 AM, Douglas Garstang doug.garst...@gmail.comwrote: I've been struggling with puppet variable scope all day, well, for

Re: [Puppet Users] Variable Scoping = Root Canal

2010-06-27 Thread Douglas Garstang
On Sun, Jun 27, 2010 at 11:28 AM, Steve Neuharth steve.neuha...@gmail.com wrote: I think you could do: node 'node1.fr.xxx.com' {  include facility::sjc  $my_ldap_server = $facility::sjc::ldap_server  include ldap::client } That seems to work. Not pretty though. I'll go see if it causes any

Re: [Puppet Users] Variable Scoping = Root Canal

2010-06-27 Thread Steve Neuharth
Yup, I hear ya. This was a pain until I realized that the only variables defined in nodes are inherited from node to node. The variables defined in classes that are included by the node must be expressed using the variable's full context. I just ended up mapping certain variables to other