[Puppet Users] Sometimes getting 'undef' in template

2013-01-06 Thread Brian Lalor
Morning, all.  I've got a problem with a custom class and template that has me 
stumped.  I've created the following class:

class graphite::carbon(
$cache_port = 2003,
$cache_enable_udp = false,
$cache_udp_port = $cache_port,
) {
package {'carbon': }

file {'/etc/carbon/carbon.conf':
content = template(graphite/carbon.conf.erb),

require = Package['carbon'],
notify  = Service['carbon-cache'],
}

service {'carbon-cache':
enable  = true,
ensure  = running,

require = Package['carbon'],
}
}

carbon.conf.erb contains this:

UDP_RECEIVER_PORT = %= cache_udp_port %

And I use the class like this:

class {'graphite::carbon': }

The problem I'm having is that, without making any changes *AT ALL* 
UDP_RECEIVER_PORT will sometimes have the default port of 2003 and other 
times undef.  This is with Puppet 2.7.17 in standalone mode.

Am I doing something wrong with the definition of cache_udp_port?  I want it to 
default to the value provided for cache_port, which defaults to 2003.

Thanks,
Brian

-- 
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] Sometimes getting 'undef' in template

2013-01-06 Thread Stefan Schulte
On Sun, Jan 06, 2013 at 08:54:23AM -0500, Brian Lalor wrote:
 Morning, all.  I've got a problem with a custom class and template that has 
 me stumped.  I've created the following class:
 
 class graphite::carbon(
 $cache_port = 2003,
 $cache_enable_udp = false,
 $cache_udp_port = $cache_port,
 ) {
 package {'carbon': }
 
 file {'/etc/carbon/carbon.conf':
 content = template(graphite/carbon.conf.erb),
 
 require = Package['carbon'],
 notify  = Service['carbon-cache'],
 }
 
 service {'carbon-cache':
 enable  = true,
 ensure  = running,
 
 require = Package['carbon'],
 }
 }
 
 carbon.conf.erb contains this:
 
 UDP_RECEIVER_PORT = %= cache_udp_port %
 
 And I use the class like this:
 
 class {'graphite::carbon': }
 
 The problem I'm having is that, without making any changes *AT ALL* 
 UDP_RECEIVER_PORT will sometimes have the default port of 2003 and other 
 times undef.  This is with Puppet 2.7.17 in standalone mode.
 
 Am I doing something wrong with the definition of cache_udp_port?  I want it 
 to default to the value provided for cache_port, which defaults to 2003.
 
 Thanks,
 Brian
 

No you are doing nothing wrong except that variable interpolation is
random so you get random results if the default value of parameterA
depends on the value of parameterB.

This has been accepted as a bug so you may want to watch
http://projects.puppetlabs.com/issues/9848

-Stefan

-- 
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] Sometimes getting 'undef' in template

2013-01-06 Thread Brian Lalor
On Jan 6, 2013, at 12:32 PM, Stefan Schulte stefan.schu...@taunusstein.net 
wrote:

 No you are doing nothing wrong except that variable interpolation is
 random so you get random results if the default value of parameterA
 depends on the value of parameterB.
 
 This has been accepted as a bug so you may want to watch
 http://projects.puppetlabs.com/issues/9848

Damn.  Thanks for confirming it's not just me. :-)

-- 
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] Custom function and SERVER: wrong argument type Class (expected Module)

2013-01-06 Thread Michael Siroskey


I have created a custom function that I'm trying to use in my manifest.  
When  I use the function I get the following error message on my client.


Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
wrong argument type Class (expected Module) at 
/etc/puppet/manifests/nodes.pp:18 on node fubar

Warning: Not using cache on failed catalog

Error: Could not retrieve catalog; skipping run


I have tested my function on server with a simple manifest locally and the 
function works properly.  The function I’ve created was to pad the contents 
of a variable with tabs so when the variable is used in a configuration it 
will have the proper alignments for readability.  Below is my function, 
I’ve removed parameter checking to simplify the code for troubleshooting. 


module Puppet::Parser::Functions

  newfunction(:talign, :type = :rvalue, :doc = -EOS

Pads a string with tabs for alignment purposes.


*Examples:*


taligh(‘abcd’,24,8)


Will return:


abcd\t\t

EOS

  ) do |arguments|


value = arguments[0]

space = arguments[1]

if arguments.size == 2

  tabsize = 8

else

  tabsize = arguments[2]

end


size = space.to_i - value.length

if size = 0

  result = value + \t

else

  count = size / tabsize.to_i

  while count  0 do

value = value + \t

count = count - 1

  end

  result = value

end


return result

  end

end


Here is the code that I’ve added to my manifest for testing. 


$temp = talign('abc',24,8)

notify{${temp}:}


Thanks,

Michael

-- 
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/-/vSdin1p-ziwJ.
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: inspect resources that are already added to a manifest

2013-01-06 Thread Peter Brown
On 3 January 2013 20:08, Luke Bigum luke.bi...@lmax.com wrote:

 On Wednesday, January 2, 2013 3:51:37 PM UTC, jcbollinger wrote:



 On Saturday, December 22, 2012 12:20:10 PM UTC-6, Luke Bigum wrote:

 Hi all,

 Does anyone know of a way to inspect resources that are already parsed
 in a node's manifest during catalog compilation? This would certainly need
 some serious Ruby Fu.



 This is a bad idea.  If your the Puppet circuits in your brain didn't
 trip over inspect, they certainly should have sounded the alarm over
 serious Ruby Fu.  You are fighting against the tool.




 As an example, imagine I have a number of arbitrary files defined by
 multiple classes and it is impossible to get an all encompassing list of
 these files:

 file { 'woof': }
 file { 'cows': }
 file { 'meow': }
 ...
 $all_files = inline_template(...)

 I would like to be able to gather those file names into a Puppet
 variable - this would be parse order dependent. It would be fantastic if it
 could handle exported resources that have just been collected as well.



 And parse-order dependent?  Of course it is.  You need a
 Puppet-bogometer.

 So what configuration objective are you actually trying to accomplish
 here?  There is likely a more robust, less Rubyriffic way to accomplish it.


 Ohh don't worry, John, my bogometer was going off like crazy, the needle
 almost broke ;-)

 I'm taking shortcuts in my spare time with a tool that's probably 70%
 right for the job. It's for monitoring - I really like the idea of a Puppet
 module to describe or advertise how to monitor itself, it keeps them very
 self contained.

 Just a bit more on this - I generally see three categories of monitoring
 tools. Ones that are configured separately from your CRM and end up being a
 source of truth on their own are in my mind the worst. The next level up
 are ones either defined from or derived from your CRM. The best are
 auto-discovery, but they cost an absolute fortune. I'm trying to move my
 team from the first one to the second one with as little new tools as
 possible, which is where the 70% right for the job comment comes from.

 I'm using exported resources to describe how modules are monitored. The
 problem is that exported resources are not the equivalent of raw
 information passing. So when I want to start doing trickier things like
 group and analyse what is collected, exported resources don't cut it
 because it's not what they are designed for.

 Specifically what I was trying to do was collect exported resources of the
 same type and group them on the monitoring server. There is no predefined
 list of service names anywhere (unless you parse the node definitions) so
 that's why I wanted to go from resource collection to Array of Strings. A
 colleague has managed to reduce my 300 lines to 50 though so the need for
 craziness is reduced somewhat. We still need to do the Export a File
 trick and run a script on the monitoring server to build the complex
 configuration that exported resources are not designed to handle.



You have made me curious.

I am going to make some wild assumptions and probably leap to some
incorrect conclusions.

Querying PupptDB seems like the wrong way to achieve this in my opinion.

I put my monitoring (and firewall rules incidentally) into each class on a
node and import into my monitoring server (nagios currently but intend on
switching to icinga soon) them based on tags.
I was using global vars but are currently rewriting my modules to use heira
to set the monitoring server and a few other settings.
This is working nicely for me.
I had a few different ideas along the way but my current iteration is
getting close to awesome.
It also gives me fine grained control over whether a node gets sms alerts
or escalation and such.

Is this the kind of thing you are attempting to achieve?

I can provide extra complexity to how it works if you need it.


 The next iteration of this work might be to scrap resource collection in
 favour of querying PuppetDB directly to figure out what to monitor, but
 that's a lot more work than I'm prepared to do at this stage. Maybe in a
 few months... ;-)

 -Luke

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

 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] file copy, multiple ignore doesn't work

2013-01-06 Thread Peter Brown
More a random question than anything.
I am going to assume the .hg files are from mercurial.
Assuming this I am wondering why you aren't using something like
puppetlabs-vcsrepo on puppet forge to deploy the directory via mercurial.
It seems like a better idea in my brain.

Pete.

On 3 January 2013 07:17, iamauser tapas.sara...@gmail.com wrote:

 I am trying the following to recursively copy a dir while ignoring things
 like .hg and a few others.

 file {
   /etc/work-related-dir :
   source = /path/to/masterfiles/work-related-dir,
   recurse = 'inf',
   owner = '0',
   group = '0',
   ignore = '{.hg,*.conf~}',
   checksum = 'mtime',
   backup = false;
 }

 Running a noop mode tries to copy everything including the one that
 matches .hg, *.conf~. If I specify only a single parameter value for
 ignore, i.e. .hg, then it doesn't try the copy of .hg directory and works
 as expected.

 Following an earlier post about this, I checked Ruby's globing options,and
 found that the pattern I am providing matches multiple files in the source
 area.

 Any help or suggestion would be appreciated.

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



[Puppet Users] How can i pass runtime parameters while installing .bin file in puppet?

2013-01-06 Thread lalit jangra
Hi,

I have alfresco .bin installer file for linux distribution which i want to 
automate using puppet. While installing alfresco on linux ,usually i need 
to provide a number of parameters such as java_home, db home, alfresco home 
or tomcat port etc.

Now i want to install same .bin installer using puppet but not getting how 
can i provide same runtime argument in puppet installation. Can anybody 
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/-/fC9PMTMYS84J.
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.