[Puppet Users] Using hiera-data for a specific node

2014-07-23 Thread Matthias Viehweger
Hi list!

I have a problem integrating puppet and hiera.

Our puppet-master and all nodes are running puppet 3.6.2. On the master,
hiera version 1.3.4 is installed.

I want to use some hiera-data in a class depending on the node. To be
less abstract, I have this class:

  class memcached::server{
$cap = hiera('memcached.cap', 64)

# package and service omitted here

if is_integer($cap) {
  file { '/etc/memcached.conf':
ensure = present,
content= template('memcached/memcached.conf.erb'),
notify = Service['memcached'];
  }
} else {
  fail(memory \$cap should be an integer)
}
  }

In a future refactoring, I may promote $cap to be a class-parameter
and also use the validation from the stdlib.

But first, I want to get 'memcached.cap' from a node-specific file.

Puppet is configured with hiera_config = /etc/puppet/hiera.yaml.
The file /etc/puppet/hiera.yaml is as follows:

  ---
  :backends: yaml
  :yaml:
:datadir: /var/lib/hiera
  :hierarchy:
- %{clientcert}
- common
  :logger: console

This is - from the docs - the internal default with just one hierarchy 
added.

I do not have the value memcached.cap in the /var/lib/hiera/common.yaml
I do have a file /var/lib/hiera/shop-01.hoster.de which contains

  memcached.cap: 256

Using this configs manually via the CLI, I get the expected result:

  $ sudo hiera memcached.cap -d -c /etc/puppet/hiera.yaml -y 
/var/lib/puppet/yaml/facts/shop-01.hoster.de.yaml
  DEBUG: Wed Jul 23 18:49:39 +0200 2014: Hiera YAML backend starting
  DEBUG: Wed Jul 23 18:49:39 +0200 2014: Looking up memcached.cap in YAML 
backend
  DEBUG: Wed Jul 23 18:49:39 +0200 2014: Looking for data source 
shop-01.hoster.de
  DEBUG: Wed Jul 23 18:49:39 +0200 2014: Found memcached.cap in 
shop-01.hoster.de
  256

So far, everything is nice. BTW, when I change the %{clientcert} to
%{::clientcert} is does work through the CLI anymore.

I cannot get the same data through puppet.

What am I doing wrong? Where - apart from the source-code - can I look
for information how that lookup works?

Thanks,
Matthias Viehweger

-- 
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/9933888a-1607-4473-87f2-e47439df844a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Using hiera-data for a specific node

2014-07-23 Thread Matthias Viehweger
Am Mittwoch, 23. Juli 2014 19:13:47 UTC+2 schrieb Atom Powers:

 Is the value of 256 being resolved by puppet as a string?
 That would cause your is_integer test to fail.


Well, if that test fails, then my core problem - getting the data at all - 
is solved. 

I expect that the conversion from YAML-types to Puppet-types is lossless in 
this case, because ruby does the right thing here and puppet would need to 
make an effort to get it wrong ;-)

But that would be a nice catch. thanks, Atom Powers.


On Wed, Jul 23, 2014 at 10:01 AM, Matthias Viehweger 
 m.vie...@heute-kaufen.de javascript: wrote:

 Hi list!

 I have a problem integrating puppet and hiera.

 Our puppet-master and all nodes are running puppet 3.6.2. On the master,
 hiera version 1.3.4 is installed.

 I want to use some hiera-data in a class depending on the node. To be
 less abstract, I have this class:

   class memcached::server{
 $cap = hiera('memcached.cap', 64)

 # package and service omitted here

 if is_integer($cap) {
   file { '/etc/memcached.conf':
 ensure = present,
 content= template('memcached/memcached.conf.erb'),
 notify = Service['memcached'];
   }
 } else {
   fail(memory \$cap should be an integer)
 }
   }

 In a future refactoring, I may promote $cap to be a class-parameter
 and also use the validation from the stdlib.

 But first, I want to get 'memcached.cap' from a node-specific file.

 Puppet is configured with hiera_config = /etc/puppet/hiera.yaml.
 The file /etc/puppet/hiera.yaml is as follows:

   ---
   :backends: yaml
   :yaml:
 :datadir: /var/lib/hiera
   :hierarchy:
 - %{clientcert}
 - common
   :logger: console

 This is - from the docs - the internal default with just one hierarchy 
 added.

 I do not have the value memcached.cap in the /var/lib/hiera/common.yaml
 I do have a file /var/lib/hiera/shop-01.hoster.de which contains

   memcached.cap: 256

 Using this configs manually via the CLI, I get the expected result:

   $ sudo hiera memcached.cap -d -c /etc/puppet/hiera.yaml -y 
 /var/lib/puppet/yaml/facts/shop-01.hoster.de.yaml
   DEBUG: Wed Jul 23 18:49:39 +0200 2014: Hiera YAML backend starting
   DEBUG: Wed Jul 23 18:49:39 +0200 2014: Looking up memcached.cap in YAML 
 backend
   DEBUG: Wed Jul 23 18:49:39 +0200 2014: Looking for data source 
 shop-01.hoster.de
   DEBUG: Wed Jul 23 18:49:39 +0200 2014: Found memcached.cap in 
 shop-01.hoster.de
   256

 So far, everything is nice. BTW, when I change the %{clientcert} to
 %{::clientcert} is does work through the CLI anymore.

 I cannot get the same data through puppet.

 What am I doing wrong? Where - apart from the source-code - can I look
 for information how that lookup works?

 Thanks,
 Matthias Viehweger

  -- 
 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...@googlegroups.com javascript:.
 To view this discussion on the web visit 
 https://groups.google.com/d/msgid/puppet-users/9933888a-1607-4473-87f2-e47439df844a%40googlegroups.com
  
 https://groups.google.com/d/msgid/puppet-users/9933888a-1607-4473-87f2-e47439df844a%40googlegroups.com?utm_medium=emailutm_source=footer
 .
 For more options, visit https://groups.google.com/d/optout.




 -- 
 Perfection is just a word I use occasionally with mustard.
 --Atom Powers-- 


-- 
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/c2261e66-2c59-41e5-8f3b-3af12fcfef6c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] how to check whether a linux process is running?

2013-02-13 Thread Matthias Viehweger
Hi Oliver!

On Tue, Feb 12, 2013 at 07:53:55PM -0800, oliver zhang wrote:
 How do I do this in puppet:
 
 if process A is running, do nothing.
 
 else mount share and install package A
 
 I couldn't find any reference about this.

I would first ensure that the process is running (assuming that it's a
service). The service would require the package which would require the
share to be mounted.

A rough outline would be:

  service { 'A':
ensure = running,
require = Package['A'];
  }

  package { 'A':
 ensure = installed,
 require = Exec['mount share'];
  }

  exec { 'mount share':
command = '...',
if = command to check if not mounted;
  }

I may be wrong, of course, but this would be my first try to resolve
this.

Cheers,
Matthias
-- 
Serververwaltung und Softwareentwicklung
 
https://www.heute-kaufen.de
Prinzessinnenstraße 20 - 10969 Berlin


signature.asc
Description: Digital signature


Re: [Puppet Users] Deprecating PostgreSQL versions 8.4 for use with PuppetDB

2013-01-03 Thread Matthias Viehweger
Hi deepak!

Coming from the ruby/rails community this is an super friendly
ahead-of-time deprecation idea notice..

On Wed, Jan 02, 2013 at 02:21:21PM -0800, Deepak Giridharagopal wrote:
 Hello! We'd like to deprecate some fairly old and crusty PostgreSQL
 versions (anything older than 8.4) for use with PuppetDB. There are a few
 reasons we want to do this:

On one hand, this is probably how it should be with infrastructure
projects like this. On the other hand, I just like both the reasoning
and the tone.

Thanks!
Matthias Viehweger
-- 
Serververwaltung und Softwareentwicklung
 
https://www.heute-kaufen.de
Prinzessinnenstraße 20 - 10969 Berlin


signature.asc
Description: Digital signature


Re: [Puppet Users] Coverage reports of manifests

2013-01-02 Thread Matthias Viehweger
Hi Vincent!

On Tue, Dec 25, 2012 at 03:26:55PM -0800, Vincent Janelle wrote:
 Is there a way of determining spec testing reports of manifests?  I'm 
 adding tests to an existing deployment and it'd be useful to find out what 
 code isn't being tested.

I am not aware of such a tool. Also, I do not think that this is easily
possible. Testing (both with rspec and cucumber) puppet means checking
the compiled catalog. A mapping back to the declarative manifests which
are also split into multiple files trhough modules and assembled back
together by types and classes is difficult.

Personally, I set up a guard (file-system watcher) that executes the
tests when I change something. For testing existing declarations, I have
the following process:

1. write the test that resembles the current state
2. if the new test is green, I check by commenting out the puppet code.

3. repeat step 1 and 2 until the test fails without the puppet code
4. commit the new test into version control, have the production active
   again and run all tests to see if the test also works in the complete
   run.

5. after commiting to version control, I use the opportunity to clean up
   the code a little, maybe document better or something like that, but
   that's the developer in me. :)

Cheers,
Matthias Viehweger
-- 
Serververwaltung und Softwareentwicklung
 
https://www.heute-kaufen.de
Prinzessinnenstraße 20 - 10969 Berlin


signature.asc
Description: Digital signature


Re: [Puppet Users] Re: puppetlabs/apt and apt::ppa

2013-01-02 Thread Matthias Viehweger
Hi Gareth!

On Wed, Dec 26, 2012 at 11:34:07AM +, Gareth Rushgrove wrote:
 I'm not sure why the module has a dependency on something that it
 doesn't manage though, I tend to try and avoid doing that if possible.

I have those in my modules a lot. Otherwise I would get god-modules or
wrong ordering.

In this case, the apt/sources.list.d-directory is a direct concern of
apt and should IMHO be managed by the module.

Cheers,
Matthias
-- 
Serververwaltung und Softwareentwicklung
 
https://www.heute-kaufen.de
Prinzessinnenstraße 20 - 10969 Berlin


signature.asc
Description: Digital signature


Re: [Puppet Users] Multiple Requires not allowed, not sure what this is for...

2012-12-22 Thread Matthias Viehweger
Hi John!

On Fri, Dec 21, 2012 at 08:36:27PM -0800, John Moser wrote:
 I'm having a case where, as with Puppet, multiple packages use the same 
 file.  For example, puppet and puppetmaster both use /etc/puppet/puppet.conf

You can declare a list of requires for a resource. Something like:

  service { 'postgresql':
ensure  = running,
require = [
  File[/etc/postgresql/9.1/main/postgresql.conf],
  Package[postgresql]
]
  }

Both file and package are handled first and need to be in the catalog.

I use this often, when I have some module that has a dependency on e.g.
Service[apache2], but does not deal with that on it's own. Puppet ensures then
that the webserver is declared in the catalog and the vhost I am
concerned with has no problems.

Cheers,
Matthias Viehweger
-- 
Serververwaltung und Softwareentwicklung
 
https://www.heute-kaufen.de
Prinzessinnenstraße 20 - 10969 Berlin


signature.asc
Description: Digital signature


Re: [Puppet Users] Unit-Testing/test: recommended method?

2012-12-13 Thread Matthias Viehweger
Hi!

On Thu, Dec 13, 2012 at 11:42:19AM -0800, Nan Liu wrote:
 On Thu, Dec 13, 2012 at 11:01 AM, Andreas Haerter 
 list+puppet-us...@mail-node.com wrote:
  1) I know there are different, well-known methods:
  - Test::Unit
  - rspec-puppet
  - cucumber-puppet
 
  Is there anything missing worth a look? Which are deprecated, wich are
  future-proof?
 
 Not aware of Test::Unit. Cucumber Puppet is deprecated. rspec-puppet is
 the way to go.

rspec-puppet is great for testing an isolated module.

For testing a complete machine or all of the catalog, I very much prefer
cucumber-puppet. That's why I forked the repo and develop it further [1].
ruby 1.9 and puppet 3 are supported by my fork.

If you use Puppet 2.7 and Ruby 1.8, I recommend the official gem. If you
have puppet 3, the you could give my fork a try. Up until now, it's just
a few fixes, I haven't had the time to integrate them into the bigger
picture with backwards compatibility and so on.

I have puppet-lint and cucumber-puppet integrated into my Jenkins-setup.

Cheers,
Matthias Viehweger

[1] https://github.com/kronn/cucumber-puppet
-- 
Serververwaltung und Softwareentwicklung
 
https://www.heute-kaufen.de
Prinzessinnenstraße 20 - 10969 Berlin


signature.asc
Description: Digital signature


Re: [Puppet Users] Puppet with dedicated ruby install

2012-12-12 Thread Matthias Viehweger
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

Hi Alexander!

On Wed, Dec 12, 2012 at 12:54:56PM -0800, Alexander Philipp wrote:
 Are there any good guides out there to using Puppet agents with a 
 dedicated, separate ruby install?  Our apps are all Ruby based and require 
 different versions than Puppet.  Installing the agent from a package will 
 override our ruby installs.

We do this the other way around. Puppet runs on system ruby (Ubuntu's
Ruby 1.8) while the apps have their dedicated rvm-setup.

Cheers,
Matthias Viehweger
- -- 
Serververwaltung und Softwareentwicklung
 
https://www.heute-kaufen.de
Prinzessinnenstraße 20 - 10969 Berlin
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.4.11 (GNU/Linux)

iQEcBAEBAgAGBQJQyQxhAAoJENF9b50VgROLtFAIAJP6X0F+VN3iSBYWoQrnE+zb
hwq1wK+Jrj3+ZY75dWGOM7IoAG5e6HGSiNdAH2J3Xu2SmOvWl183WTb4gsfNFL+Y
w0p+o/imkWzJJ1G+rjvUAAVI85YeEVgXDOmd5GQGND37Wt/97v0ou7mFf/rb1yC7
gQX1msuz3Py/p1QOU1QgL+X8UGVsc4FhOFtd6+zZGGodsbYq+AWukY4QKkYP+3t2
uJOELYS9ObR1T4WeliW2bDd/1jb/80lFOWZdtErZL6gEd3x63W/DPBjV/DpP949c
CY1Rjoy84Uqq4PVb3R3xT73qYxLW2dtgZCmZlA+C2rbJkD624XV8CErMwRum4ic=
=2aA9
-END PGP SIGNATURE-

-- 
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: Do you want a Puppet Conference in Berlin, Germany

2012-11-25 Thread Matthias Viehweger
Hi!

Am Montag, 19. November 2012 09:02:35 UTC+1 schrieb Martin Alfke:

 I am thinking about running a Puppet Conf in Berlin/Germany. 


Awesome idea, I was looking for something like that here.

Are there any people on this list from nearby? 


I live in Berlin.
 

 Do you want to support (talk, workshop)? 


I would like to give a talk, maybe even a workshop, depending on the 
interest.

Cheers,
Matthias Viehweger

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