[Puppet Users] Variables and scope with inherits

2012-08-12 Thread Svein
I want to have a parametrized class with lookup from params.pp but I keep 
getting into problems.

 

init.pp:
class foo (
  $bar = $foo::params::bar,
  $foofoo = $foo::params::foofoo
) inherits foo::params   {
  file {'/tmp/foobar':
content => template("foo/foobar.erb"),
  }

}
params:
class foo::params {
  $bar = true
  if $foo::bar {
$foobar = 'yes'
$foofoo = 'foo'
   } 
  else {
$foobar = 'no'
$foofoo = 'bar'
  }
}

foobar.erb:
<% if scope.lookupvar('foo::boo') -%>
<%= scope.lookupvar('foo::foofoo') %>
<% end -%>
<%= scope.lookupvar('foo::params::foobar') %>
<%= scope.lookupvar("foo::foofoo") %>
When I run puppet on the class I get:
puppet apply --modulepath=/modules/ foo/test/init.pp 
warning: Scope(Class[Foo::Params]): Could not look up qualified variable 
'foo::bar'; class foo has not been evaluated at 
/modules/foo/manifests/params.pp:3
warning: Scope(Class[Foo::Params]): Could not look up qualified variable 
'foo::bar'; class foo has not been evaluated at 
/modules/foo/manifests/params.pp:3
notice: Finished catalog run in 0.02 seconds
and the file looks like:
/tmp/foobar:
bar
no
bar


If I use include params.pp instead of inherits puppet gives:
puppet apply --modulepath=/modules/ foo/test/init.pp 
warning: Scope(Class[Foo]): Could not look up qualified variable 
'foo::params::bar'; class foo::params has not been evaluated at 
/modules/foo/manifests/init.pp:2
warning: Scope(Class[Foo]): Could not look up qualified variable 
'foo::params::bar'; class foo::params has not been evaluated at 
/modules/foo/manifests/init.pp:2
warning: Scope(Class[Foo]): Could not look up qualified variable 
'foo::params::foofoo'; class foo::params has not been evaluated at 
/modules/foo/manifests/init.pp:3
warning: Scope(Class[Foo]): Could not look up qualified variable 
'foo::params::foofoo'; class foo::params has not been evaluated at 
/modules/foo/manifests/init.pp:3
and the file looks like.
/tmp/foobar:
undef
no
undef


What I want it to look like is of cause:
bar
yes
bar

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/5v355b9Eo0QJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] puppet class and user groups question

2012-08-12 Thread devzero2000
For situation like this define the group as a virtual group , better
yet define a  module that contain the virtual group including it in
your class and "realize" it when necessary. Or sometime better use the
"spaceship" operator if you want to realize with a command multiple
user resources, virtual of course, for example.

Check virtual resources here
Http://docs.puppetlabs.com/guides/

hth



2012/8/13, Andrew :
> Hi all,
> so,
> summary: I am cant think of a way to supply group creds on the same group to
> two different classes that both require access to the ssl certificates. The
> ssl certs are group but not world accessible, 'mode => 660'.
>
> I have ldap doing tls, in one class, so the ldap user needs to be in the
> sslcerts group, and httpd::ssl, so apache needs to be in the sslcerts
> group.
>
> how can I create the group so both classes can add their users to the group
> ?
>
> Thanks in advance,
> Andrew.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/vSTbyOvGfsMJ.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.
>
>

-- 
Inviato dal mio dispositivo mobile

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] Re: Ruby Facter.add syntax please help

2012-08-12 Thread karl
have now found the solution so not to worry thanks. problem was that a 
extra "end" was missing

On Monday, August 13, 2012 2:01:07 PM UTC+10, karl wrote:
>
> Hi,
>
> Please could someone take a look at the below code and tell me where it is 
> failing ?
>
> Facter.add('syslocation') do
> #confine :kernel => "Linux"
>   setcode do
> name = Facter.value('hostname')
> case name
> when /^e(t|d|u|s|p|q)(p|v)(sol|lin)\d+/
> "E DC"
> when /^b(t|d|u|s|p|q)(p|v)(sol|lin)\d+/
> "F DC"
> when /^a(t|d|u|s|p|q)(p|v)(sol|lin)\d+/
> "G DC"
> when /^vx*\d+/
> "A DC"
> when /^vm*\d+/
> "V DC"
> when /^adl*\d+/
> "H DC"
> else
> #"RFF DC"
> name
> end
> end
>
> Could not find value for 'syslocation' at 
> 13:/etc/puppet/modules/rpd_snmp/templates/snmpd.conf.erb at 
> /etc/puppet/modules/rpd_snmp/manifests/init.pp:21
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/vI7fzNZ1JxEJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] puppet class and user groups question

2012-08-12 Thread Andrew
Hi all,
so,
summary: I am cant think of a way to supply group creds on the same group to 
two different classes that both require access to the ssl certificates. The ssl 
certs are group but not world accessible, 'mode => 660'.

I have ldap doing tls, in one class, so the ldap user needs to be in the 
sslcerts group, and httpd::ssl, so apache needs to be in the sslcerts group.

how can I create the group so both classes can add their users to the group ?

Thanks in advance,
Andrew.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/vSTbyOvGfsMJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] Ruby Facter.add syntax please help

2012-08-12 Thread karl
Hi,

Please could someone take a look at the below code and tell me where it is 
failing ?

Facter.add('syslocation') do
#confine :kernel => "Linux"
  setcode do
name = Facter.value('hostname')
case name
when /^e(t|d|u|s|p|q)(p|v)(sol|lin)\d+/
"E DC"
when /^b(t|d|u|s|p|q)(p|v)(sol|lin)\d+/
"F DC"
when /^a(t|d|u|s|p|q)(p|v)(sol|lin)\d+/
"G DC"
when /^vx*\d+/
"A DC"
when /^vm*\d+/
"V DC"
when /^adl*\d+/
"H DC"
else
#"RFF DC"
name
end
end

Could not find value for 'syslocation' at 
13:/etc/puppet/modules/rpd_snmp/templates/snmpd.conf.erb at 
/etc/puppet/modules/rpd_snmp/manifests/init.pp:21

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/qq_iqOna9UUJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] syntax change or regression?

2012-08-12 Thread Trevor Vaughan
Though not elegant, you could also run it through an inline template.

Alternatively, you could write a puppet function that manipulates your
data structure appropriately and returns an appropriate answer for you
to use in your selector.

Trevor

On Sun, Aug 12, 2012 at 1:11 PM, Justin Stoller  wrote:
> On Sun, Aug 12, 2012 at 1:35 AM, Samuel José Martín  wrote:
>>
>> Hi,
>>
>> I am using puppet to generate ipsec tunnels configuration on OpenBSDs
>> gateways.
>> Having a bunch of offices, I did something like this:
>>
>> $enc = $office ?
>> {
>> "paris" =>
>> {
>> "london" => "aes",
>> "kiev" => "3des"
>> },
>> "london" =>
>> {
>> "paris" => "aes",
>> "kiev" => "3des"
>> },
>> "kiev" =>
>> {
>> "paris" => "3des",
>> "london" => "3des"
>> }
>> }
>>
>> This may not be the cleaner way, since I have to specify each variable two
>> times - the enc for tunnel from paris to london is obviously the same as the
>> one from london to paris.
>> However, this works, under OpenBSD 4.9 and our production puppetmaster
>> (2.6).
>>
>> Now, we want to upgrade our firewalls to OpenBSD 5.0.
>> Their puppet client version (2.7.1) is forcing us to upgrade our
>> puppetmaster too.
>>
>> My test puppetmaster is running debian wheezy, with puppet* 2.7.14-1.
>> While executing puppetd -vt on the client, it fails compiling catalog, with
>> some syntax error "at '{'; expected '}'".
>> I've just updated my puppetmaster to 2.7.18-1, no changes since my last
>> check.
>> The faulty "{" is the second one (in my sample, the one just after "paris").
>>
>> Is this some regression, in ruby or puppetmaster?
>> Or is this kind of syntax deprecated in any way?
>> Is there any replacement?
>
> I think you've found this:
> https://projects.puppetlabs.com/issues/14301   --   Hashes can not be
> used in selectors
>
> I don't know how it sits in the deprecated/regression realm.
> I think updating your thoughts in the ticket would help move it
> forward in development though.
>
>> What could I do to patch my repository, before upgrading our production
>> puppetmaster?
>
> For the time being (if you don't want to refactor your module in
> otherways) you can always assign the hash outside of the selector
> (my_test.pp)
>
> $office = 'paris'
>
> $paris  = { "london" => "aes",  "kiev" =>   "3des" }
> $london = { "paris"  => "aes",  "kiev" =>   "3des" }
> $kiev   = { "paris"  => "3des", "london" => "3des" }
>
> $enc = $office ?  {
>   "paris" => $paris,
>   "london" => $london,
>   "kiev" => $kiev
> }
>
> notify { $enc['london']: }
>
>
>
>
>  - Justin
>
>>
>>
>> Thanks for your help,
>>
>> Regards.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msg/puppet-users/-/dJiuo5sjBYwJ.
>> To post to this group, send email to puppet-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> puppet-users+unsubscr...@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/puppet-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
>



-- 
Trevor Vaughan
Vice President, Onyx Point, Inc
(410) 541-6699
tvaug...@onyxpoint.com

-- This account not approved for unencrypted proprietary information --

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] syntax change or regression?

2012-08-12 Thread Justin Stoller
On Sun, Aug 12, 2012 at 1:35 AM, Samuel José Martín  wrote:
>
> Hi,
>
> I am using puppet to generate ipsec tunnels configuration on OpenBSDs
> gateways.
> Having a bunch of offices, I did something like this:
>
> $enc = $office ?
> {
> "paris" =>
> {
> "london" => "aes",
> "kiev" => "3des"
> },
> "london" =>
> {
> "paris" => "aes",
> "kiev" => "3des"
> },
> "kiev" =>
> {
> "paris" => "3des",
> "london" => "3des"
> }
> }
>
> This may not be the cleaner way, since I have to specify each variable two
> times - the enc for tunnel from paris to london is obviously the same as the
> one from london to paris.
> However, this works, under OpenBSD 4.9 and our production puppetmaster
> (2.6).
>
> Now, we want to upgrade our firewalls to OpenBSD 5.0.
> Their puppet client version (2.7.1) is forcing us to upgrade our
> puppetmaster too.
>
> My test puppetmaster is running debian wheezy, with puppet* 2.7.14-1.
> While executing puppetd -vt on the client, it fails compiling catalog, with
> some syntax error "at '{'; expected '}'".
> I've just updated my puppetmaster to 2.7.18-1, no changes since my last
> check.
> The faulty "{" is the second one (in my sample, the one just after "paris").
>
> Is this some regression, in ruby or puppetmaster?
> Or is this kind of syntax deprecated in any way?
> Is there any replacement?

I think you've found this:
https://projects.puppetlabs.com/issues/14301   --   Hashes can not be
used in selectors

I don't know how it sits in the deprecated/regression realm.
I think updating your thoughts in the ticket would help move it
forward in development though.

> What could I do to patch my repository, before upgrading our production
> puppetmaster?

For the time being (if you don't want to refactor your module in
otherways) you can always assign the hash outside of the selector
(my_test.pp)

$office = 'paris'

$paris  = { "london" => "aes",  "kiev" =>   "3des" }
$london = { "paris"  => "aes",  "kiev" =>   "3des" }
$kiev   = { "paris"  => "3des", "london" => "3des" }

$enc = $office ?  {
  "paris" => $paris,
  "london" => $london,
  "kiev" => $kiev
}

notify { $enc['london']: }




 - Justin

>
>
> Thanks for your help,
>
> Regards.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/puppet-users/-/dJiuo5sjBYwJ.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/puppet-users?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



Re: [Puppet Users] variable scoping?

2012-08-12 Thread devzero2000
On Sun, Aug 12, 2012 at 2:43 PM, Eric Shamow  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
> graph."
>
It is an import concept. It is very simple to think "include" in puppet ==
"include" in C. No, they are much different

>
> It's important not to think of Puppet in procedural, top-down terms. We
> haven't just said, "give me all the stuff in this class, and now do these
> things." Rather we are building a model of a server, and manifest code
> simply informs pieces of that model. So by saying "include " you are
> really saying, "Puppet, if you haven't already, make sure this class is
> part of the overall resource graph."
>
> The better model for this example is, rather than a box inside of a box,
> you are looking at two sealed boxes sitting side by side. When you include
> the first group, it is added to the list of boxes used. Within the first
> box, when you then say "give me the second box," that second box is placed
> *alongside* the first. Thus in order to grab anything from it, you have to
> specify "I need the stuff from box 2."
>
> Does that analogy help a bit more?
>
> The reason for this is that, as your number of classes grows, so too will
> your variables. If they share a single global namespace, the likelihood of
> a global variable name being used more than once increases. This can lead
> to really unexpected changes and ambiguity in building the graph.
>
> 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 the model of
> your system, which of the two is to be applied where? Dynamic scoping tried
> to guess at this. The idea here is to say, eliminate ambiguity - tell us
> exactly which one you want.
>
> In fact, this is the best analogy.  But clearly it is easy for everyone to
make mistakes especially if you are following the examples of "Pro Puppet"
- incidentally, this book contains the same configuration discussed in this
thread that was valid for puppet 2.6 but it is not anymore for puppet 2.7

Best Regards

> -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 --> http://bit.ly/pcsig12
>
>
> On Sunday, August 12, 2012 at 2:35 AM, Zachary Alex Stern wrote:
>
> > 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 original puppet::params class?
> >
> > How can I change variables on the fly effectively, if I can't just do
> the import and then have the variable $puppetserver equal the one from the
> imported class? I'm having a hard time grasping what import does, if not
> 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 -
> > >
> > > 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 introduce some sanity to variable scopes and eliminate
> dynamic scoping, which causes all kinds of pain.
> > >
> > > The easiest way to think about scoping in general is that a scope is
> defined by its container. If I put something physical in a box, I have
> access to it the moment I open the box, and other objects inside the box
> can interact with it. If, however, I now put that box inside a second box,
> the objects in the second box cannot interact directly with the objects in
> the first - the first object is protected by its container.
> > >
> > > Scoping mostly works the same way. The right way to get at the
> variable is to always explicitly scope, as you began to get at below with
> your scope.lookupvar example. As that can be a bit of a pain to repeat, you
> can always copy the value into a local variable:
> > >
> > > class puppet::config {
> > > include puppet::params
> > > $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 -->
> http://bit.ly/pcsig12
> > >
> > >
> > > On Saturday, August 11, 2012 at 8:45 PM, Zachary Stern wrote:
> > >
> > > > I'm having a really hard time grasping ho

Re: [Puppet Users] Installing Modules.

2012-08-12 Thread Dan White
First suggestion: Update your Puppet to 2.7.14+
Then this will work:
http://docs.puppetlabs.com/puppet/2.7/reference/modules_installing.html#installing-from-the-puppet-forge

Contrarywise, you go here:
https://github.com/puppetlabs/puppetlabs-lvm
and click on the button that says "Zip" with the picture of the little cloud 
with a down arrow on it.

That downloads a file puppetlabs-puppetlabs-lvm-.zip

Unzip it.  Rename the folder from puppetlabs-puppetlabs-lvm- 
to lvm and then copy/move it into your puppet master's modules folder.

Any more questions ? The list is here.

Good luck.  Hope this helps.

On Aug 12, 2012, at 1:33 AM, Douglas Garstang wrote:

> Someone directed me to this...
> 
> http://forge.puppetlabs.com/puppetlabs/lvm
> 
> How do you install these...? The documentation at
> http://docs.puppetlabs.com/puppet/2.7/reference/modules_installing.html
> says to use the puppet module command... where? On the server? The
> docs also say this isn't available until puppet 2.7.14, and we're
> using 2.7.1. How do I install?
> 
> Doug
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Users" group.
> To post to this group, send email to puppet-users@googlegroups.com.
> To unsubscribe from this group, send email to 
> puppet-users+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/puppet-users?hl=en.
> 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



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 terms. We haven't 
just said, "give me all the stuff in this class, and now do these things." 
Rather we are building a model of a server, and manifest code simply informs 
pieces of that model. So by saying "include " you are really saying, 
"Puppet, if you haven't already, make sure this class is part of the overall 
resource graph."

The better model for this example is, rather than a box inside of a box, you 
are looking at two sealed boxes sitting side by side. When you include the 
first group, it is added to the list of boxes used. Within the first box, when 
you then say "give me the second box," that second box is placed *alongside* 
the first. Thus in order to grab anything from it, you have to specify "I need 
the stuff from box 2."

Does that analogy help a bit more?

The reason for this is that, as your number of classes grows, so too will your 
variables. If they share a single global namespace, the likelihood of a global 
variable name being used more than once increases. This can lead to really 
unexpected changes and ambiguity in building the graph.

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 the model of your system, which of 
the two is to be applied where? Dynamic scoping tried to guess at this. The 
idea here is to say, eliminate ambiguity - tell us exactly which one you want.

-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 --> http://bit.ly/pcsig12   


On Sunday, August 12, 2012 at 2:35 AM, Zachary Alex Stern wrote:

> 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 original puppet::params class?
>  
> How can I change variables on the fly effectively, if I can't just do the 
> import and then have the variable $puppetserver equal the one from the 
> imported class? I'm having a hard time grasping what import does, if not 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 -  
> >  
> > 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 introduce some sanity to variable scopes and eliminate dynamic 
> > scoping, which causes all kinds of pain.  
> >  
> > The easiest way to think about scoping in general is that a scope is 
> > defined by its container. If I put something physical in a box, I have 
> > access to it the moment I open the box, and other objects inside the box 
> > can interact with it. If, however, I now put that box inside a second box, 
> > the objects in the second box cannot interact directly with the objects in 
> > the first - the first object is protected by its container.  
> >  
> > Scoping mostly works the same way. The right way to get at the variable is 
> > to always explicitly scope, as you began to get at below with your 
> > scope.lookupvar example. As that can be a bit of a pain to repeat, you can 
> > always copy the value into a local variable:  
> >  
> > class puppet::config {  
> > include puppet::params  
> > $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 --> http://bit.ly/pcsig12  
> >  
> >  
> > On Saturday, August 11, 2012 at 8:45 PM, Zachary Stern wrote:  
> >  
> > > 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 => template('puppet/puppet.conf.erb'),  
> > > owner => 'root',  
> > > group => 'admins',  
> > > require => Class['puppet::install'],  
> > > notify => Class['puppet::service'],  
> > > }  
> > > }  
> > > ###  
> > >  
> > >

Re: [Puppet Users] Return value from a define?

2012-08-12 Thread Erik Dalén
On 12 August 2012 08:30, Douglas Garstang  wrote:
> So, general puppet design question. I have a definition called
> create_vg that creates an lvm volume group. An input to this is
> obviously the list of physical disks. In a  normal programming
> language, I'd put the identification of the physical disks into one
> function, and pass the result of that to create_vg().
>
> However, since a define in puppet can't return a value (can it?), you
> don't have many options unless you want to set it as a fact with
> fact-add, which bothers me, because your effectively than accumulating
> a list of global variables that may not need to be variable.
>
> So, your effectively left with putting the logic that determines the
> physical disks _inside_ create_vg(). No? Seems so... non functional!
>

Defines are pretty much equivalent to defining new resource types,
they don't define a function.
If you want to create a function that calculates something and returns
a value, have a look at creating custom functions in ruby:

http://docs.puppetlabs.com/guides/custom_functions.html

-- 
Erik Dalén

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.



[Puppet Users] syntax change or regression?

2012-08-12 Thread Samuel José Martín

Hi,

I am using puppet to generate ipsec tunnels configuration on OpenBSDs 
gateways.
Having a bunch of offices, I did something like this:

$enc = $office ?
{
"paris" =>
{
"london" => "aes",
"kiev" => "3des"
},
"london" =>
{
"paris" => "aes",
"kiev" => "3des"
},
"kiev" =>
{
"paris" => "3des",
"london" => "3des"
}
}

This may not be the cleaner way, since I have to specify each variable two 
times - the enc for tunnel from paris to london is obviously the same as 
the one from london to paris.
However, this works, under OpenBSD 4.9 and our production puppetmaster 
(2.6).

Now, we want to upgrade our firewalls to OpenBSD 5.0.
Their puppet client version (2.7.1) is forcing us to upgrade our 
puppetmaster too.

My test puppetmaster is running debian wheezy, with puppet* 2.7.14-1.
While executing puppetd -vt on the client, it fails compiling catalog, with 
some syntax error "at '{'; expected '}'".
I've just updated my puppetmaster to 2.7.18-1, no changes since my last 
check.
The faulty "{" is the second one (in my sample, the one just after "paris").

Is this some regression, in ruby or puppetmaster?
Or is this kind of syntax deprecated in any way?
Is there any replacement?
What could I do to patch my repository, before upgrading our production 
puppetmaster?


Thanks for your help,

Regards.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/puppet-users/-/dJiuo5sjBYwJ.
To post to this group, send email to puppet-users@googlegroups.com.
To unsubscribe from this group, send email to 
puppet-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/puppet-users?hl=en.