[Puppet Users] Re: Extending a defined type

2016-09-08 Thread Matthew Pounsett


On Thursday, 8 September 2016 07:54:07 UTC-4, amateo wrote:
>
>
> So I'm thinking the possibility to create my own types extending 
> them. 
> Is there any documentation about extending types. All documentation I 
> have found is about creating a completely new type, but I haven't found 
> any about inheriting an existing one. 
>


You can fairly easily extend a resource or type by wrapping it in a new one 
of your own making.  The concept is similar to inheritance in object 
oriented languages, but the mechanism is a little less sleek.

I'm picking a resource with a small list of attributes to keep the example 
simple, but you can do this with anything.

define my_notify (
  $name => $title,
  $message  => undef,
  $withpath => undef,
  $my_notify_special,
){
  # do custom things here
  notify { $title:
name => $name,
message  => $message,
withpath => $withpath,
  }
  # do more custom things here, maybe with $my_notify_special
}


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/c8379491-eb4c-4b0c-ba76-ddaadcadc5c7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] puppet4 stdlib (4.12.0) error with .find method?

2016-09-07 Thread Matthew Pounsett


On Wednesday, 7 September 2016 19:11:04 UTC-4, Henrik Lindberg wrote:
>
>
> The call to `find` is in Ruby, not in puppet. There are numerous calls 
> to find in the Ruby code base. 
>

Yeah, all the stuff I was looking at was ruby.  It hadn't occurred to me to 
check the puppet codebase itself though. 
 

> To find where the error is run the compilation with --trace and look at 
> the logged exception - it will tell you where in Ruby the error 
> occurred. From there is should be able to trace backwards. 
>

Aha.. --trace is a big help there.  It looks like a bug in the pkgng 
provider, possibly?
 

>
> If you are on the latest 4.x the backtrace will include puppet function 
> calls as well as Ruby methods to make this easier. 
>

I'm running 4.5.1.  It doesn't look like the puppet calls were included, to 
me.  
 

>
> The error: 
>Error: Failed to apply catalog: undefined method `find' for 
> nil:NilClass 
>
> may come from an `undef` value (translated to Ruby nil in Ruby if you 
> are using future parser or 4.x) 
>
> Hope this helps pin down where the problem is. 
>

Yeah, I think I found it.   zleslie/pkgng failed to create the repository 
config I asked it to, while deleting the pre-existing default repository (I 
had purge_repos_d set to true).  It looks like in the absence of a 
functioning repository, the pkgng provider fails to handle the condition of 
there being no available packages to install, or even list.

Thanks for your help!

% sudo puppet agent -t --trace
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppet.localdomain
Info: Applying configuration version '1473304882'
Error: Failed to apply catalog: undefined method `find' for nil:NilClass
/usr/local/lib/ruby/site_ruby/2.2/puppet/provider/package/pkgng.rb:66:in `block 
in prefetch'
/usr/local/lib/ruby/site_ruby/2.2/puppet/provider/package/pkgng.rb:65:in 
`each'
/usr/local/lib/ruby/site_ruby/2.2/puppet/provider/package/pkgng.rb:65:in 
`prefetch'
/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction.rb:305:in `prefetch'
/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction.rb:205:in 
`prefetch_if_necessary'
/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction.rb:97:in `block in 
evaluate'
/usr/local/lib/ruby/site_ruby/2.2/puppet/graph/relationship_graph.rb:116:in 
`call'
/usr/local/lib/ruby/site_ruby/2.2/puppet/graph/relationship_graph.rb:116:in 
`traverse'
/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction.rb:142:in `evaluate'
/usr/local/lib/ruby/site_ruby/2.2/puppet/resource/catalog.rb:222:in `block 
in apply'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util/log.rb:155:in 
`with_destination'
/usr/local/lib/ruby/site_ruby/2.2/puppet/transaction/report.rb:118:in 
`as_logging_destination'
/usr/local/lib/ruby/site_ruby/2.2/puppet/resource/catalog.rb:221:in `apply'
/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:171:in `block in 
apply_catalog'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util.rb:223:in `block in benchmark'
/usr/local/lib/ruby/2.2/benchmark.rb:303:in `realtime'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util.rb:222:in `benchmark'
/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:170:in 
`apply_catalog'
/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:315:in `run_internal'
/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:186:in `block in run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/context.rb:65:in `override'
/usr/local/lib/ruby/site_ruby/2.2/puppet.rb:240:in `override'
/usr/local/lib/ruby/site_ruby/2.2/puppet/configurer.rb:185:in `run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:45:in `block (4 levels) 
in run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent/locker.rb:21:in `lock'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:45:in `block (3 levels) 
in run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:98:in `with_client'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:42:in `block (2 levels) in 
run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:65:in `run_in_fork'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:41:in `block in run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application.rb:179:in `call'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application.rb:179:in 
`controlled_run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/agent.rb:39:in `run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application/agent.rb:353:in `
onetime'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application/agent.rb:331:in 
`run_command'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application.rb:344:in `block in 
run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util.rb:540:in `exit_on_fail'
/usr/local/lib/ruby/site_ruby/2.2/puppet/application.rb:344:in `run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util/command_line.rb:128:in `run'
/usr/local/lib/ruby/site_ruby/2.2/puppet/util/command_line.rb:72:in `execute
'
/usr/local/bin/puppet:5:in `'

-- 
You received this message because you are subscribed to the Google Groups 

[Puppet Users] puppet4 stdlib (4.12.0) error with .find method?

2016-09-07 Thread Matthew Pounsett

Having just installed zleslie/pkgng in order to ma nage repositories on my 
FreeBSD hosts (which in turn required and installed puppetlabs/stdlib), I'm 
now getting the following error from my puppet runs:

% sudo puppet agent -t
Info: Using configured environment 'production'
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for puppet.localdomain
Info: Applying configuration version '1473274285'
Error: Failed to apply catalog: undefined method `find' for nil:NilClass

I've checked, and the only place where a find method is called, anywhere, 
is within stdlib in the file_line provider and resource, and in the 
get_module_path function.

% sudo find . -type f |xargs fgrep -l .find

./modules/stdlib/lib/puppet/provider/file_line/ruby.rb

./modules/stdlib/lib/puppet/parser/functions/get_module_path.rb

./modules/stdlib/spec/unit/puppet/type/file_line_spec.rb

The only one of these called from outside of stdlib is file_line, and it's 
called by zleslie/pkgng:

% sudo find . -type f |xargs egrep -l '(file_line|get_module_path)'
./modules/stdlib/CHANGELOG.md
./modules/stdlib/examples/file_line.pp
./modules/stdlib/lib/puppet/provider/file_line/ruby.rb
./modules/stdlib/lib/puppet/type/file_line.rb
./modules/stdlib/lib/puppet/parser/functions/load_module_metadata.rb
./modules/stdlib/lib/puppet/parser/functions/get_module_path.rb
./modules/stdlib/spec/acceptance/get_module_path_spec.rb
./modules/stdlib/spec/functions/load_module_metadata_spec.rb
./modules/stdlib/spec/functions/get_module_path_spec.rb
./modules/stdlib/spec/unit/puppet/type/file_line_spec.rb
./modules/stdlib/spec/unit/puppet/provider/file_line/ruby_spec.rb
./modules/stdlib/README.markdown
./modules/stdlib/checksums.json
./modules/pkgng/manifests/init.pp

I've tried temporarily commenting out the call to file_line that appears in 
the pkgng module, and that does not make the error go away.

I'm left with the conclusion that there's a bug in stdlib, but the lack of 
debug output makes this hard to track down.   Anyone have any suggestions 
for further nailing down which use of 'find' is the error?  

Or is this a known bug?


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/4babef51-20d7-4375-9be8-d210874b2534%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: How to refer to exported resource parameters in a template

2016-08-09 Thread Matthew Pounsett


On Tuesday, 9 August 2016 06:12:33 UTC-7, jcbollinger wrote:
>
>
>
> Some people do hack together means to do the job more or less as you 
> initially envisioned, but don't confuse mechanism with result.  I would not 
> be surprised if you had seen examples of exactly what I describe, without 
> recognizing that they, or something like them, would serve your purpose 
> perfectly well.
>

Using concat for this purpose represents the worst of ugly hacks to get 
around a missing feature.   I've been forced to use it before for similar 
purposes.. and in any kind of large infrastructure it can quickly become an 
unmanageable collection of thousands of files being concatenated into a 
single (or small number of) config files.

If accessing the values in exported resources is such anathema, then 
perhaps the puppet core aught to consider including a function that exposes 
facts across nodes.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/01feb2e9-7404-47b2-b436-2fa4a35e5ad4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] How to refer to exported resource parameters in a template

2016-08-08 Thread Matthew Pounsett


On Monday, 8 August 2016 14:02:39 UTC-7, Christopher Wood wrote:
>
> On Mon, Aug 08, 2016 at 11:28:55AM -0700, Matthew Pounsett wrote: 
> >I'm using puppet 4.4.1.  I have a case where I need the IP addresses 
> of 
> >all the servers that fit a certain set of criteria to appear in a 
> YAML 
> >list in a config file on a particular host. 
>
> Been there for an activemq.xml config file, ended up using Erik Dalén's 
> puppetdbquery. 
>
> https://forge.puppet.com/dalen/puppetdbquery 
>

That looks like it quite neatly solves the problem.
Thanks!

 

>
> This in a manifest: 
>
> $qf = query_facts('id=root', ['owner', 'datacenter']) 
>
> This in a template used in that manifest: 
>
> <% 
> list = {} 
> @qf.values.each do |h| 
>   if h['owner'] 
> owner = h['owner'] 
> list[owner] = 1 
>   end 
>   if h['datacenter'] 
> datacenter = h['datacenter'] 
> list[datacenter] = 1 
>   end 
> end 
> -%> 
>
> You get the idea, could output yaml there or whatever you wanted really. 
>
> >It seems like the first step would be to create an exported resource 
> with 
> >the required data in it, but I haven't yet found a way to refer to 
> those 
> >data from inside a template (or from inside a module in order to 
> populate 
> >a variable I can use in a template).   It seems like this would be a 
> >common pattern, but the closest examples I've been able to find are 
> for 
> >realizing the exported resource to create a file or other resource on 
> a 
> >system, rather than incorporate some of the exported resource's data 
> in 
> >other resources. 
> >How do people normally go about doing something like this?  Are there 
> some 
> >examples I've just failed to find? 
> > 
> >-- 
> >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 [1]puppet-users...@googlegroups.com . 
> >To view this discussion on the web visit 
> >[2]
> https://groups.google.com/d/msgid/puppet-users/d60d5c64-babe-4b46-8529-ceac74cf576b%40googlegroups.com.
>  
>
> >For more options, visit [3]https://groups.google.com/d/optout. 
> > 
> > References 
> > 
> >Visible links 
> >1. mailto:puppet-users+unsubscr...@googlegroups.com  
> >2. 
> https://groups.google.com/d/msgid/puppet-users/d60d5c64-babe-4b46-8529-ceac74cf576b%40googlegroups.com?utm_medium=email_source=footer
>  
> >3. https://groups.google.com/d/optout 
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/8eeec81b-407c-4c34-b58b-1d4352af10ec%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] How to refer to exported resource parameters in a template

2016-08-08 Thread Matthew Pounsett

I'm using puppet 4.4.1.  I have a case where I need the IP addresses of all 
the servers that fit a certain set of criteria to appear in a YAML list in 
a config file on a particular host.

It seems like the first step would be to create an exported resource with 
the required data in it, but I haven't yet found a way to refer to those 
data from inside a template (or from inside a module in order to populate a 
variable I can use in a template).   It seems like this would be a common 
pattern, but the closest examples I've been able to find are for realizing 
the exported resource to create a file or other resource on a system, 
rather than incorporate some of the exported resource's data in other 
resources.

How do people normally go about doing something like this?  Are there some 
examples I've just failed to find?





-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/d60d5c64-babe-4b46-8529-ceac74cf576b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: most idiomatic way to set resource defaults

2016-07-12 Thread Matthew Pounsett


On Monday, 11 July 2016 10:31:45 UTC-4, R.I. Pienaar wrote:
>
>
>  best avoid create_resources in puppet 4 :) 
>

Why is that? 

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/7deabef1-2262-4c45-9825-f4371ec0bf6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: most idiomatic way to set resource defaults

2016-07-11 Thread Matthew Pounsett


On Friday, 8 July 2016 04:27:26 UTC-4, Peter Faller wrote:
>
> Are you using the create_resources function to instantiate the resources? 
> It takes a third argument containing default values:
>
> $widgets = hiera('widgets', {})
> $widget_defaults = hiera('widget_defaults', {})
> create_resources(::widget, $widgets, $widget_defaults)
>

I haven't go so far as to write that part yet, but I was thinking of 
something along those lines.   Because of the varying defaults, I would 
actually need to iterate over the customer names.  

$widgets = hiera('widgets', {})
$widget_defaults = hiera('widget_defaults', {})
$widgets.each |String $customer, Hash $data| { create_resources( ::widget, 
$widgets[$customer], $widget_defaults[$customer] }

The problem I can't solve with this approach is that which customer's 
widgets I'm creating is actually an important attribute of the widget type, 
as it relates to where files get created, etc.  This is why I was wondering 
if there was a better way to organize the data in Hiera.  I considered 
reformatting the 'widgets' dictionary into a list so that the customer name 
is an attribute, not a key:

$widgets = hiera('widgets', [])
$widget_defaults = hiera('widget_defaults', {})
$widget_defaults.each |String $customer, Hash $defaults| {
   $widget_data = $widgets.filter |$data| { $data['customer'] == $customer }
   create_resources( ::widget, $widget_data, $widget_defaults[$customer])
}

That gets repetitive and doesn't organize  as well, however.  

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/d822f840-5247-4d3e-ad9c-e6169fb4a273%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] most idiomatic way to set resource defaults

2016-07-07 Thread Matthew Pounsett

I have a defined resource type (let's call it `widget`) which gets defined 
multiple times per customer.  Each customer has their own default 
configuration values for their widgets, and these are very rarely (but 
occasionally) overridden.   I'd like to minimize the amount of typing 
necessary when someone adds a new widget to the systems, so I'm thinking of 
a Hiera structure similar to this:

widget_defaults:
   customer1:
 colour: green
 size: big
 outline: vague
   customer2:
 colour: blue
 size: big
 outline: crisp

widgets:
   customer1:
  foo:{}
  bar:
 colour: violet
  baz:{}
   customer2:
  froop:{}
  vroom:{}
  blargh:
 outline: circular

This will require multiple hiera lookups inside the profile that 
instantiates the resources though, in order to merge the defaults with any 
override values.   Is there a more idiomatic way to deal with something 
like this?


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/f90c1a2e-d597-4594-b06f-3051e34641fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] most idiomatic way to set resource defaults

2016-07-07 Thread Matthew Pounsett
I have a defined resource type (let's call it `widget`) which can be 
defined multiple times per customer.  Each customer has different default 
values for their set of widgets which are rarely overridden, and I'd like 
to minimize the typing necessary when someone adds a new widget to a 
customer's list.

I'm thinking of a hiera structure similar to this:

widget_defaults:



widget_defaults:

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/f97251c7-9432-411d-8d7f-8c8b1f6fd7a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] PE missing referents for production modules

2016-05-03 Thread Matthew Pounsett


On Tuesday, May 3, 2016 at 10:02:30 AM UTC-4, Lindsey Smith wrote:
>
>
>
> On Mon, May 2, 2016 at 1:54 PM, Matthew Pounsett <matthew@rightside.co 
> > wrote:
>
>>
>> I'm setting up a test deployment of the latest PE.  I haven't run PE for 
>> a couple of years, and it looks like a few (perhaps a lot of) things have 
>> changed.
>>
>> I have a completely fresh install of 
>> puppet-enterprise-2016.1.1-el-7-x86_64 on Centos 7.  I've added a module as 
>> /etc/puppetlabs/code/environments/production/modules/vim, and run a restart 
>> of the PE service (systemctl reload-or-restart pe-puppetserver.service).  
>>
>> However, when I try to add my new 'vim' class to the All Nodes group and 
>> Commit the change, I'm getting a (rather large) missing-referents error.  
>>
>> I've double-checked that the module file declares the class properly, and 
>> that the perms should allow the server process to read the modules.  The 
>> docs  don't seem to mention any other steps I need to follow.  Clearly I'm 
>> missing something newly added to the process though.  Anyone have any 
>> pointers?
>>
>
> I believe that you need to create a child group of All Nodes first, and 
> add the vim class to that group. There is an interaction between All Nodes 
> and assignment of environment in other groups such that you can't add 
> classes to All Nodes.
>

This appears to have been it: an issue with adding classes to the All Nodes 
group.   I found that adding a child group of All Nodes didn't have the 
anticipated effect of inheriting the list of affected nodes .. I still had 
to set my own regex match in order to pull nodes in.  But, it did the job.

Thanks!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/3888e611-bf2e-4b50-970d-fccdfa965b35%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] PE missing referents for production modules

2016-05-03 Thread Matthew Pounsett

I'm setting up a test deployment of the latest PE.  I haven't run PE for a 
couple of years, and it looks like a few (perhaps a lot of) things have 
changed.

I have a completely fresh install of puppet-enterprise-2016.1.1-el-7-x86_64 
on Centos 7.  I've added a module as 
/etc/puppetlabs/code/environments/production/modules/vim, and run a restart 
of the PE service (systemctl reload-or-restart pe-puppetserver.service).  

However, when I try to add my new 'vim' class to the All Nodes group and 
Commit the change, I'm getting a (rather large) missing-referents error.  

I've double-checked that the module file declares the class properly, and 
that the perms should allow the server process to read the modules.  The 
docs  don't seem to mention any other steps I need to follow.  Clearly I'm 
missing something newly added to the process though.  Anyone have any 
pointers?


-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/6959bfcd-ff48-47bb-aa37-c2a7d38d8f8b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: Using exported resources as data containers?

2014-09-10 Thread Matthew Pounsett
On 10 September 2014 07:30, Daniel Siechniewicz dan...@siechniewicz.com
wrote:

 Hi,

 Sounds like a job for https://github.com/dalen/puppet-puppetdbquery
 potentially? pdbresourcequery or maybe even the hiera backend.


Hiera doesn't apply here, because it's data gathered from the servers
(mostly from facts) where the config snippets are defined.  Putting that
sort of thing in Hiera violates Don't Repeat Yourself.  I'll have a look at
the others though.. I'm not familiar with them.  Thanks for the suggestions.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAKZ22fLmwD0eqXs7DttKydpZjPBTJMJq0PcQY28vpnbO%3D7mxGg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: Using exported resources as data containers?

2014-09-10 Thread Matthew Pounsett
On 10 September 2014 08:08, Daniel Siechniewicz dan...@siechniewicz.com
wrote:

 Hi,

 This particular hiera backend, from what I understand, is extracting
 values from puppetdb on the fly, so you don't have to put any values
 in hiera yaml/json files save for a relevant puppetdb query. This
 would centralize data gathering and localize it to a data component.
 Otherwise you end up with puppetdb queries within your manifests which
 could be not what you want. Then again, this really depends on your
 preferences. Good luck and tell us if this worked for you.

 It looks like it's designed to deal with facts and classes only.  I really
need something that can get data from resources (defined types).  It's
crappy design, but I could move *some* of the global variables defined in
my type's module into facts to make those available, but I don't see a
decent way to get data out of the resources, so I don't think it solves the
whole problem.

Thanks for the suggestion though.. this looks like it could be very useful
to simplify a couple other things I've been looking at.

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAKZ22fLvPWyy4rcaiDEWq1tda777hTAf6PBAXBJKgmjS627s9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Using exported resources as data containers?

2014-09-10 Thread Matthew Pounsett
On 10 September 2014 12:57, José Luis Ledesma joseluis.lede...@gmail.com
wrote:

 Perhaps you can use datacat_fragments exported resources and then collect
 them   and put them together with the datacat_collector.

 https://github.com/richardc/puppet-datacat/


That looks really promising.  It'll take me a bit to wrap my head around
it, because I think I'll need to refactor a couple of things to use it...
but I think I can make it do what I need.

Thanks!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAKZ22f%2BnuKETYmKLxeRh7wdU%3DTuzizM5preHJThCgN8%3DABQPEA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Extending a standard type

2013-01-29 Thread Matthew Pounsett


On Tuesday, 29 January 2013 00:29:43 UTC-5, Keith Burdis wrote:

 You can set the default values to undef and then the standard user type 
 will use its defaults (if any).  It usually makes sense to default the 
 ensure parameter to 'present' though because if it is undef then nothing 
 will happen:


Ah, I see... I'd tried using empty strings, but for some reason undef never 
occurred to me.  Thanks, it looks like this will work perfectly.




-- 
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+unsubscr...@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.




[Puppet Users] Re: How to assign variable for an URL

2013-01-29 Thread Matthew Pounsett


On Tuesday, 29 January 2013 02:05:30 UTC-5, yarlagadda ramya wrote:

 Hi all,

 I have written the following code...

 $someendpoint1=12345
 $someendpoint2=54321
 $prop = /app/tcs/temp.properties

 file{'temp.properties':
 path =$prop,
 ensure ='present',
 content =$someendpoint1=http://sdrhuiswresw:8080/ersfrsdrs/sdersrsrs
 $someendpoint2=http://sdrhuiswresw:8080/ersfrsdrs/sdersrsrs;
 }

 actually i want to apply variables to the link..when am trying to do that 
 am getting an error. How can i assign the variables to link???


If I understand your request properly.. just the same as you're applying 
variables elsewhere.

$someendpoint1=12345
$someendpoint2=54321
$prop = /app/tcs/temp.properties
$uri_path = /ersfrsdrs/sdersrsrs

file{'temp.properties':
path =$prop,
ensure ='present',
content 
=$someendpoint1=http://sdrhuiswresw:8080/http://sdrhuiswresw:8080/ersfrsdrs/sdersrsrs
$uri_path
$someendpoint2=http://sdrhuiswresw:8080/http://sdrhuiswresw:8080/ersfrsdrs/sdersrsrs
$uri_path
 
If you have a case where the variable name is ambiguous because it's up 
against another string that could be part of the variable:.

e.g.
$foo = super
$bar = $foostar

Then you have to enclose the variable name in curly quotes to remove the 
ambiguity:

$foo = super
$bar = ${foo}star

Some people consider it good style to do this all the time.

However, I'm only guessing at what errors you might be seeing.  If you 
could supply the real example of what you're trying to do, with the error 
you're getting, it would make it easier to give you specific advice.

-- 
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+unsubscr...@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.




[Puppet Users] Re: Puppet Site.pp hierarchy (multi-tenant) question

2013-01-29 Thread Matthew Pounsett


On Tuesday, 29 January 2013 04:34:56 UTC-5, jim wrote:

 The easiest option would be to add different manifests for different 
 groups / teams within site.pp, but if I make changes to the sub-manifests, 
 i'd need to touch the site.pp file for changes to kick in, which could 
 also effect the other teams / group changes and cause outages ?

 Can some please recommend the best approach to multi-tenant or at least 
 pass on your experiences ?


You probably have several difference choices that might have different 
drawbacks or benefits depending on exactly how you're managing things.   
One option that comes to mind is to use something like 'environments' to 
define a different site.pp file for each tenant.  Each tenant could claim 
the machines under their control by setting a property on the console or in 
the agent's puppet.conf like so:

[agent]
tenant = teamA

In your master's puppet.conf, something like this:

[master]
manifest = /usr/local/etc/puppet/tenant/${tenant}/manifests/site.pp 

And so Team A's site.pp would be at:
/usr/local/etc/puppet/tenant/teamA/manifests/site.pp

You could arrange the directory/manifest structure there any way you want. 
 This would be equally as valid:
[master]
manifest = /usr/local/etc/puppet/manifests/${tenant}-site.pp 

Any method of getting the 'tenant' global variable defined would work. 
 Which to choose is a matter of pereference.  Some examples: a puppet.conf 
definition, a custom fact, a piece of data pulled from Hiera...  The 
documentation on setting up environments might be of interest to you. 
 http://docs.puppetlabs.com/guides/environment.html


-- 
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+unsubscr...@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.




Re: [Puppet Users] Referencing a variable from one class in another

2013-01-29 Thread Matthew Pounsett


On Tuesday, 29 January 2013 10:07:29 UTC-5, Ti Leggett wrote:

 I'm not sure I fully agree with this from a design standpoint. In 
 object-oriented programming, one of the design principles is that variables 
 relating to the object are encapsulated within the object and exposed or 
 not depending on how they should be accessed. IMHO, it also makes it more 
 obfuscated when you're accessing say the SSL CA cert path variable and 
 that's in some 'common' module that everything has to include. Granted it 
 makes it easier on the module developer - just always in include the common 
 module and your variables should be there - but it also makes it less 
 explicit.


How would you handle variables that wouldn't otherwise be tied to a module?

An example I ran into when I was doing our first deployment was the path to 
various shells.  They vary from OS to OS, but rarely (if ever) need a whole 
module to manage them.  The paths get referenced in many places, such as 
when adding users or installing scripts (erb used in the bangpath).  I've 
found it useful to have things like $::site::params::bash and 
$::site::params:tcsh for shells, and other site-wide variables for other 
things.  It means I only need to put the case logic to figure out the path 
based on the OS in one place, and not have it scattered around several 
modules that all need to figure out the same thing.


-- 
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+unsubscr...@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.




Re: [Puppet Users] Referencing a variable from one class in another

2013-01-29 Thread Matthew Pounsett


On Tuesday, 29 January 2013 13:58:20 UTC-5, Ti Leggett wrote:

 I include that in the module that installs the shell packages and 
 configures them, in my case, I call it base. In other words, the variables 
 should be as close to the things they affect or are affected by. Just 
 because every node might include base (or site) doesn't mean every variable 
 you'll ever want to use should be in there. That, to me, creates a messier 
 and more confusing dependency relationship between modules that use a 
 variable and what that variable ultimately affects.


If you have a module that installs and configures those shells, then great. 
 But many systems come with those shells preinstalled, and there's nothing 
to manage.   Perhaps shells were a bad example, since one of tcsh or bash 
may need to be added to an OS by puppet.  What about the path to sed? 
 That's part of the base OS for all systems I manage, but the path varies 
from OS to OS.   It seems overly cumbersome to me to create an entire 
module just to assign one variable, and then repeat that for a dozen or so 
other variables with similar circumstances.  It seems cleaner to have a 
single small module that contains site-wide definitions that aren't 
obviously tied to modules of their own. 

-- 
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+unsubscr...@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.




[Puppet Users] Re: Extending a standard type

2013-01-28 Thread Matthew Pounsett


On Monday, 28 January 2013 11:14:59 UTC-5, jcbollinger wrote:
 

 define site::user (
 $comment,
 $ensure,
 $home,
 $name = $title,



 Don't do that ($name = $title).  Puppet provides it automatically (both 
 the parameter and the default).


In this case, $name is the login name of the user being created .. it's a 
valid parameter of the 'user' resource type.  I'm not sure how I'm supposed 
to do not use it.  I have read the Puppet reference manual.. but not for 
puppet 3, since I'm not using that.  

 

 Moreover, I am uncertain whether it is safe anyway to use $title as a 
 resource default.  It certainly *isn't* safe to use explicit resource 
 properties, regardless of the order in which they are listed.


I'n not sure what you mean by that.  Using $title as a default is widely 
used (see namevar) .. I'm not sure what you mean about explicit resource 
properties.


 The usual paradigm is this:
 define mymodule::foo ( $param1 = 'NOTSET' ) {
   $real_param1 = $param1 ? {
 'NOTSET' = some-appropriate-value-maybe-undef,
 default = $param1
   }
   sometype { $name:
 param = $real_param1
   }
 }
 Yes, it's a bit clunky, but it works.

 

This is great if I want to set my own defaults, but I don't.  The 'user' 
resource already has its own way of handling unspecified parameters, and I 
don't want to override those unless absolutely necessary.   I think the 
above would require me to re-implement a bunch of its defaults logic, which 
would be especially problematic for things like 'gid'.  

 

 No, Puppet doesn't have anything like that.  The closest would probably be 
 the create_resources() function, which you can read about in the docs.


I'll have a look.. maybe there's some way I can make use of it.
 

 I'm surprised you didn't find an example like the one above.  It appears 
 all over the place, not least in the archives of this group.

Also, have you read the official Puppet DSL docs (at 
 http://docs.puppetlabs.com/puppet/3/reference/)?  They don't answer your 
 particular question, but they would have told you about $name, and they 
 have a lot of other useful information.


The only occurrence of the string name in the DSL doc at that location is 
as a placeholder... and it applies to ruby, not puppet manifests.  I don't 
see anything there about use of $name inside a puppet class.


-- 
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.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




[Puppet Users] Extending a standard type

2013-01-26 Thread Matthew Pounsett
I'm trying to extend the standard 'user' type to add maintenance of some of 
the contents of a user's home directory, and I'm trying to avoid creating 
an entirely new custom type if I can.  The approach I'm taking is to create 
a site::user defined type which in turns calls the standard user type.  I'm 
having a problem figuring out how to manage the optional parameters.  

The most likely path seems to be something like this (simplified for 
example):

define site::user (
$comment,
$ensure,
$home,
$name = $title,
$password,
) {

user { $title:
comment = $comment,
ensure = $ensure,
home = $home,
name = $name,
password = $password,
}
}

The problem with this, of course, is that the parameters to site::user 
aren't optional, and I'd like them to be.  I've tried setting their 
defaults to null strings, but I get errors about reassigning variables if I 
do that.  

Of course, this would be even better.. but doesn't appear to be a valid 
syntax in puppet:

define site::user ( $**args ) {
   user { $title:
  $args
   }
}

This seems to me to be the sort of thing that'd be in a puppet cookbook, 
but google hasn't shown me any useful docs or examples for what I'm trying 
to do.  Does this approach even make sense, or is there a better way?

-- 
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.
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Puppet Users] Re: puppetmaster fails to start using dist puppet.conf file

2011-02-18 Thread Matthew Pounsett

On 2011/02/16, at 07:11, randomcontrol wrote:

 I removed the facts directory and puppet now starts without
 problems, but it doesn't create a facts-file or -directory
 automatically.

I reached the same conclusion.  I still have no idea why the complaint or even 
really what generated it.. in all the reading I've done I've never seen 
anything that describes what appears to be a default manifest that the puppet 
master applies to its own system. And, if it is indeed such a thing, I think 
it's weird that it only does it in the presence of a config file.

Also of note, after a bit of digging into the build process, I established that 
the default config file I referenced in my original email is actually generated 
by 'puppetmasterd --genconfig' so I find it even more strange that it doesn't 
work out of the box.



-- 
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] Making dependencies work with variable resource names

2011-02-16 Thread Matthew Pounsett

On 2011/02/16, at 03:44, Felix Frank wrote:

 Hi,
 
 here's what I'd do:
 
 
  Devices::Device_node {
  dir = $homedir/${service_num}/dev/,
  require = File[$homedir/${service_num}/dev/],
  }

I tried that as well (noted in the original post).  That's what generated the 
error that I included.

Feb 11 17:18:40 puppet-bsd2 puppet-agent[68963]: Could not run Puppet 
configuration client: Could not find dependency File[/opt/home/2/dev/] for 
Exec[create-device-/opt/home/2/dev/null] at 
/usr/local/etc/puppet/production/modules/devices/manifests/init.pp:12

It seems that the problem is that Puppet is expanding the variable in the 
'require' but has not yet expanded the variable in the file{} block, and so 
can't find the file resource to create the dependency tree.

 Although why your original approach didn't work is not quite fathomable
 to me. If the error persistes, try and make a simplified version of your
 manifests that reproduces the same problem. Often, this will make a
 mistake obvious (when it stops to reproduce after all).

This is exactly what I posted.  It's my actual manifests stripped down to just 
the basics required to demonstrate the problem.

 If the problem persists, use the simplified manifest in a bug report.

Okay.  Now that I know this is supposed to work, I'll go ahead and file a bug 
report.  Thanks.



-- 
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] Re: Making dependencies work with variable resource names

2011-02-16 Thread Matthew Pounsett

On 2011/02/16, at 09:20, jcbollinger wrote:

 In general, if Puppet attempts to apply resources in a sequence that
 doesn't work, then it means that there are resource relationships that
 are not implicit and have not been declared.  That's exactly the case
 in the OP's manifest: there is nothing in it that would create an
 order relation between devices::device_node instances and the
 directories named in their $dir parameters.  Exec resources are not
 documented to (and evidently do not) autorequire any part of the path
 to their 'cwd' or 'creates' parameters.  The sequence of declarations
 in the manifest is irrelevant.

Actually, yes they are documented to do that.  From the documentation for 
'require'[1]:

 Currently, exec resources will autorequire their CWD (if it is specified)
 plus any fully qualified paths that appear in the command. For instance, 
 if you had an exec command that ran the myscript mentioned above, the 
 above code that pulls the file down would be automatically listed as a 
 requirement to the exec code, so that you would always be running againts 
 the most recent version.

And, as noted in my original post, I did try replacing the 'cwd' with a 
'require', and tried moving the 'require' to the call to devices::device_node 
rather than in its definition.  Neither alternative worked.


-- 
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] Re: Making dependencies work with variable resource names

2011-02-16 Thread Matthew Pounsett

On 2011/02/16, at 10:56, Felix Frank wrote:

 Adding an appropriate requires = to Devices::device_node
 instantiations, as suggested, should do the trick.  Alternatively, the
 requires = could be put on one of the resources inside the defined
 type (in this case, the only candidate is the Exec).  Personally, I
 prefer the latter whenever it is feasible, which in this case it is.
 
 Ah, but the OP tried the latter and received an error. Again, I don't
 see why that is (possibly the manifest was censored in an unbecoming
 fashion).

Nothing there was censored.  As the original post noted, that is a stripped 
down but functioning proof of concept based on my original manifests.  


-- 
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] Re: Making dependencies work with variable resource names

2011-02-16 Thread Matthew Pounsett

On 2011/02/16, at 12:53, Matthew Pounsett wrote:

 Actually, yes they are documented to do that.  From the documentation for 
 'require'[1]:

Hrm.. I meant to include the URL there:

http://docs.puppetlabs.com/references/stable/metaparameter.html

I'll also note that I'm not too surprised you didn't know that was there.  In 
trying to get myself up to speed I've noticed a major failing in the Puppet 
documentation in that it is very badly organized.  It's not unusual for the 
important details of a particular behaviour to be spread around different parts 
of the documentation, or for it to be very difficult for a new user to even 
find the main reference to a particular piece of 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] exec: creates overrides onlyif?

2011-02-15 Thread Matthew Pounsett

On 2011/02/14, at 12:21, Daniel Pittman wrote:

 Hey.
 
 I think this discussion totally deserves a feature/bug report in redmine, 
 because both positions are reasonable. They do point to a hole where our 
 specifation seems vague, and where we *should* have made a decision: right 
 now we have a real chance of changing whatever the behaviour is by accident.
 
 Matthew, do you want to file this at https://projects.puppetlabs.com for us, 
 along with the why behind your desire?

Will do.

I'm actually mostly just concerned with having the relationship between the two 
directives clarified.  Right now the docs don't say anything about how they 
interact.  As Felix Frank wrote, I can work around the case where 'creates' 
ignores 'onlyif' by moving that test into my 'onlyif' directive.

thanks!

-- 
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] exec: creates overrides onlyif?

2011-02-14 Thread Matthew Pounsett

On 2011/02/14, at 11:12, Felix Frank wrote:

 On 02/10/2011 08:47 PM, Matthew Pounsett wrote:
 
 The docs are vague on how the two interact.. but it seems to me that 
 'creates' will override 'onlyif' in an exec clause.  i.e. if the file named 
 by 'creates' exists, then 'onlyif' is ignored.  Is someone able to confirm 
 that?
 
 I cannot positively confirm, but the opposite wouldn't make a bit of
 sense to me.

Sometimes files exist already but need to be updated.  With 'creates' and 
'onlyif' both set, I'd expect an OR behaviour: write the file if the file 
referenced by 'creates' doesn't exist, OR if 'onlyif' evaluates to true.


-- 
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] Making dependencies work with variable resource names

2011-02-11 Thread Matthew Pounsett
I'm having an issue solving dependencies inside defines, where the paths to 
various resources are variable.  It seems like puppet isn't expanding all of 
the variables when it constructs the catalog, so it's unable to find the 
resources necessary to build things in the right order.

I've constructed a simple proof of concept to demonstrate the problem.  I'm 
hoping someone can provide some advice on how this case should be handled, 
because clearly I've misunderstood how puppet is intended to be used to handle 
this sort of case.

Here is my site.pp, with a single machine loading up the module that builds a 
standard service.  Each instance of the service has its own homedir with its 
own data, logs, etc.

node puppet-bsd2.virtual {
include service
service::app {
first:
service_num =  1;
second:
service_num =  2;
}
}

Here's the init.pp manifest for the 'service' module.  It includes the 
'devices' module which is used for creating device files in a chroot 
environment, and sets up the homedir for each instance of the service.

include devices
class service {
file {
/opt:
ensure = directory,
owner = root,
group = wheel,
mode = 755;
/opt/home:
ensure = directory,
owner = root,
group = wheel,
mode = 755;
}
define app (
$homedir = /opt/home,
$service_num
) {
file {
$homedir/${service_num}:
ensure  =  directory,
owner   =  root,
group   =  wheel,
mode=  0750;
$homedir/${service_num}/dev:
ensure  =  directory,
owner   =  root,
group   =  wheel,
mode=  0750;
}
devices::device_node {
${homedir}/${service_num}/dev/null:
dir = $homedir/${service_num}/dev/;
${homedir}/${service_num}/dev/random:
dir = $homedir/${service_num}/dev/;
}
}
}

And finally, the devices module.  

class devices {
define device_node (
$dir
) {
exec {
create-device-${name}:
creates = ${name},
cwd = ${dir},
command = /usr/bin/touch ${name},
}
}
}


The problem is one of order of operations.  With the above manifests, puppet 
always tries to write the device files before it creates the 'var' directory 
that contains them.  According to the 'require' documentation, 'cwd' inside an 
exec clause should auto-require the directory referenced.  This wasn't working, 
and so I tried to change the 'cwd' to a 'require = File...' in order to make 
it more explicit.  This is what exposed the real problem to me:

Feb 11 17:18:40 puppet-bsd2 puppet-agent[68963]: Could not run Puppet 
configuration client: Could not find dependency File[/opt/home/2/dev/] for 
Exec[create-device-/opt/home/2/dev/null] at 
/usr/local/etc/puppet/production/modules/devices/manifests/init.pp:12

How do other people deal with these sorts of dependencies, where the files and 
directories being created have variable paths based on the arguments passed to 
a definition?  Is there a better way to get where I'm trying to go with this?

Any clue is highly appreciated.

-- 
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] Complex data structures: working around a parser bug

2011-02-10 Thread Matthew Pounsett
A few days ago another user posted an issue with complex hashes[1]; it looks 
like a parser bug, and a bug report was opened[2].  I seem to be having a 
similar problem, but I haven't been able to make the same workaround function.

This is the data structure I'd like to be using, but puppet doesn't like the 
array nested inside a hash:
$dev_numbers = {
'null' = {
'freebsd'   = [ 0,  6 ],
'ubuntu'= [ 1,  3 ],
},
'random' = {
'freebsd'   = [ 0, 12 ],
'ubuntu'= [ 1,  8 ],
},
'zero' = {
'freebsd'   = [ 0,  7 ],
'ubuntu'= [ 1,  5 ],
},
}

--parseonly produces an error when checking this one
err: Could not parse for environment production: Syntax error at '='; expected 
'}' 

The alternative is to replace the array with a hash, like this:
$dev_numbers = {
'null' = {
'freebsd'   = { 'major' = 0, 'minor' =  6 },
'ubuntu'= { 'major' = 1, 'minor' =  3 },
},
'random' = {
'freebsd'   = { 'major' = 0, 'minor' = 12 },
'ubuntu'= { 'major' = 1, 'minor' =  8 },
},
'zero' = {
'freebsd'   = { 'major' = 0, 'minor' =  7 },
'ubuntu'= { 'major' = 1, 'minor' =  5 },
},
}

Puppet lets me define this data structure, but I can't find a way to access it.

If I use this:
$major = $dev_numbers[$type][$operatingsystem]['major']
$minor = $dev_numbers[$type][$operatingsystem]['minor']
then --parseonly gives me a syntax error:
err: Could not parse for environment production: Syntax error at '['; expected 
']'

If I use the alternative proposed to the OP, which looks like this:
$device = $dev_numbers[$type][$operatingsystem]
$major = $device['major']
$minor = $device['minor']
then --parseonly passes everything, but when puppet actually tries to build the 
catalog for the client it fails and logs this error:
device is not an hash or array when accessing it with major at...


Does anyone have any other suggestions for how to work around this problem with 
the parser?

Thanks in advance!
   Matt



[1] 
http://groups.google.com/group/puppet-users/browse_thread/thread/8840c275ca677cd9/58d7adea821fc49f
[2] http://projects.puppetlabs.com/issues/6269

-- 
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] exec: creates overrides onlyif?

2011-02-10 Thread Matthew Pounsett

The docs are vague on how the two interact.. but it seems to me that 'creates' 
will override 'onlyif' in an exec clause.  i.e. if the file named by 'creates' 
exists, then 'onlyif' is ignored.  Is someone able to confirm that?

Thanks!

-- 
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] puppet kick and Could not set 'file on ensure: Is a directory - /var/lib/puppet/facts

2011-02-09 Thread Matthew Pounsett

On 2011/02/09, at 15:32, DigitalWonk wrote:

 Hello puppet world,
 
 I'm sure this is probably an easy fix, but I cannot seem to resolve this 
 issue.  The puppetmaster starts correctly and so does the puppet agent, which 
 receives the update correctly if I restart the puppet agent service manually 
 or during the timed updates; however, if I perform an puppet kick, it just 
 fails with the following error:

This is incredibly similar to a problem I've been having with the puppet 
master[1].  Let me know if you find a resolution.. no one has replied to my 
posting or to earlier postings about similar issues from other users.

[1] 
http://groups.google.com/group/puppet-users/browse_thread/thread/531d110306636003?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.



[Puppet Users] puppetmaster fails to start using dist puppet.conf file

2011-02-08 Thread Matthew Pounsett

I'm having an issue with the default puppet.conf distributed with puppet 2.6.4 
(FreeBSD port).  I've reproduced the problem with a completely fresh install on 
a completely fresh OS in a VM.  Under these conditions, running puppetmaster 
with no config is fine, but simply moving the puppet.conf-dist file to 
puppet.conf causes the following errors on console:

Performing sanity check of puppetmaster configuration: FAILED, puppetmaster 
exited with status 1
Could not prepare for execution: Got 1 failure(s) while initializing: change 
from directory to file failed: Could not set 'file on ensure: Is a directory - 
/var/puppet/facts
/usr/local/etc/rc.d/puppetmaster: WARNING: failed precmd routine for 
puppetmaster

and the following is logged to syslog:

Feb  8 22:34:06 puppetmaster puppet-master[14713]: (/File[/var/puppet/facts]) 
Not removing directory; use 'force' to override
Feb  8 22:34:06 puppetmaster puppet-master[14713]: (/File[/var/puppet/facts]) 
Not removing directory; use 'force' to override
Feb  8 22:34:06 puppetmaster puppet-master[14713]: 
(/File[/var/puppet/facts]/ensure) change from directory to file failed: Could 
not set 'file on ensure: Is a directory - /var/puppet/facts
Feb  8 22:34:07 puppetmaster puppet-master[14719]: (/File[/var/puppet/facts]) 
Not removing directory; use 'force' to override
Feb  8 22:34:07 puppetmaster puppet-master[14719]: (/File[/var/puppet/facts]) 
Not removing directory; use 'force' to override
Feb  8 22:34:07 puppetmaster puppet-master[14719]: 
(/File[/var/puppet/facts]/ensure) change from directory to file failed: Could 
not set 'file on ensure: Is a directory - /var/puppet/facts

/var/puppet/facts is a directory, and I'm not sure why puppet would want to 
convert it to a file, or why it would fail to do so if it really needs it to be 
a file.  

 ls -ld /var/puppet/ /var/puppet/facts/
drwxr-xr-x  12 puppet  puppet  512 Jan 25 18:00 /var/puppet/
drwxr-xr-x   2 puppet  puppet  512 Jan 25 18:00 /var/puppet/facts/

facts-related config entries in the dist puppet.conf are:

 grep fact puppet.conf | grep -v '^ *#'
factsource = puppet://puppet/facts/
factpath = /var/puppet/lib/facter:/var/puppet/facts
factdest = /var/puppet/facts/

Does anyone know what's causing this, or how to correct it?  Google is showing 
me a couple other occurrences of this with older versions, but no solutions.  


-- 
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.