[Puppet Users] Re: How to read in file into array of hashes to use build start script template

2017-01-13 Thread John Gelnaw
Set up hiera correctly, add a yaml file to your hierarchy, and and 
translate the CSV file to YAML:

I'm a perl geek, so:
#!/bin/perl

while(<>)  {
  chomp; 
  tr/A-Z/a-z/;
  my @a = split(/\,/);
  push(@{$hash{$a[0]}}, $a[1]);
}
for my $srv (sort(keys(%hash)))  {
  print "startup::$srv\n";
  for my $cmd (@{$hash{$srv}})  {
print "  - $cmd\n";
  }
}


... yes, that array syntax in the hash is hideous.  ;)

Also, I know I should be using CSV and YAML modules, but the example was 
simple enough.

That should produce something like:

startup::servera:
  - /usr/local/bin/prog start databasea
  - /usr/local/bin/prog start databaseb 
startup::serverb:
  - /usr/local/bin/prog start database123

Although I'd probably drop the "/usr/local/bin/prog start", since it seems 
to be common to all.

Then a class:

class startup  {

  $array = hiera(startup::$hostname, "none")

  if (! $array == "none") {
   < do stuff >
 }
}



I'm assuming serverb doesn't need to know servera's business (loading the 
entire thing on every server seems wasteful to me), but if it does, change 
the yaml to:

startup:
  servera:
- command 1
- command 2
  serverb:
- command 1

And then just load the entire hash:

$hash = hiera("startup")

-- 
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/496ef25d-311f-4a9c-8a4f-52abf292d6e5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: How to read in file into array of hashes to use build start script template

2017-01-13 Thread John Gelnaw

Set up hiera correctly, add a yaml file to your hierarchy, and and 
translate the CSV file to YAML:

I'm a perl geek, so:
#!/bin/perl

while(<>)  {
  chomp; 
  tr/A-Z/a-z/;
  my @a = split(/\,/);
  push(@{$hash{$a[0]}}, $a[1]);
}
for my $srv (sort(keys(%hash)))  {
  print "startup::$srv\n";
  for my $cmd (@{$hash{$srv}})  {
print "  - $cmd\n";
  }
}



startup::servera:
  - /usr/local/bin/prog start databasea
  - /usr/local/bin/prog start databaseb 
startup::serverb:
  - /usr/local/bin/prog start database123

Although I'd probably drop the "/usr/local/bin/prog start", since it seems 
to be common to all.

Then a class:

class startup  {

  $array = hiera(startup::$hostname, "none")

  if (! $array == "none") {

   < do stuff >
 }

}

I'm assuming serverb doesn't need to know servera's 

-- 
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/4f045170-082b-4c6c-95df-e3d0e80ad3c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Trouble using type Stdlib::Windowspath

2017-01-13 Thread Henrik Lindberg

On 13/01/17 12:16, Tiago Delboni wrote:

Em quarta-feira, 11 de janeiro de 2017 15:38:28 UTC-2, Henrik Lindberg
escreveu:


Maybe there is something wrong with that type.
What does this give you:

notice('C:\a\valid\path' =~ Stdlib::Windowspath)

If that fails, please report the issue against stdlib.
(Or I am blind and there is something not right about the path).


Hi Henrik

The first notice bellow returns FALSE and the second, that uses
Stdlib::Windowspath definition from
"puppetlabs-stdlib\types\windowspath.pp" returns TRUE.

notice('C:\temp' =~ Stdlib::Windowspath)

notice('C:\temp' =~
Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/])

I also defined my own Windowspath type in
"mymodule\types\windowspath.pp" and the following test returns FALSE:

notice('C:\temp' =~ Mymodule::Windowspath)

I guess it all points to a "type loading" issue - I can't use types,
even those defined inside my own module. :(



Sounds like they are in the wrong location, or that you are using a 
version of Puppet that does not support loading of types.


- henrik





--
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/beb5380e-76a4-41b3-bf8b-1b3b2f825665%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.



--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
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/fcd66f24-6719-6254-ef44-f42fde3e617b%40puppet.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] How to read in file into array of hashes to use build start script template

2017-01-13 Thread Garrett Honeycutt
On 1/13/17 4:15 PM, James Perry wrote:
> After spending most of they day digging around and researching, I find
> Puppet's immutable variables are keeping me from properly handling what
> I'm trying to do, so I want to see if anyone else has some suggestions
> on how to handle was I need to accomplish.
> 
> Goal: Ingest a CSV file provided by a user and generate a start / stop
> script, dynamically, for every server in scope, based on CSV file. 
> 
> CSV Format: 
> SERVER,start command 
> 
> Example. 
> SERVERA, /usr/local/bin/prog start databasea
> SERVERA, /usr/local/bin/prog start databaseb
> SERVER1, /usr/local/bin/prog start database123
> 
> 
> The basic design I had in mind for the manifest is to: 
> 1. Read in the file as provided,
> 2. Convert , to downcase(A) => B
> 3. if $hostname == A 
>$my_server_script_lines = $my_hash[A][B]
>file { 
>  ... 
>  content => template("basic_start_script"),
>  }
> 
> 4. Create a template that runs through the $my_server_script_lines to
>  put each start line under start) and under stop) after doing a substr
> replacement of start for stop in B. 
> 
> Code so far
> include stdlib
> $my_data = file("/home/me/database.csv")
> $my_subst = downcase(split($my_data2,'[,\n]'))
> $my_hash = hash($my_subst)
> 
> notice ($my_hash[SERVERA])
> 
> $ puppet apply --verbose test.pp
> Info: Loading facts
> *Notice: Scope(Class[main]): '/usr/local/bin/prog start databaseb'*
> Notice: Compiled catalog for myhost.net in environment production in
> 0.16 seconds
> Info: Applying configuration version '1484340247'
> Notice: Applied catalog in 0.03 seconds
> 
> Here are the values of the variables as it processes through
> 
> $my_data = "SERVERA,/usr/local/bin/prog start databasea
> SERVERA,/usr/local/bin/prog start databaseb
> SERVERB,/usr/local/bin/prog start database123"
> 
> $my_subst = [servera, '/usr/local/bin/prog start databasea' , servera,
> '/usr/local/bin/prog start databaseb' , serverb, '/usr/local/bin/prog
> start database123' ]
>  
> $my_hash = {servera => '/usr/local/bin/prog start databaseb' , serverb
> => '/usr/local/bin/prog start database123' }
> 
> So I already know why the hash conversion dropped the "start databasea"
> for the servera key, what I can't seem to figure out is how to have it
> convert into a array of value pairs for a specific key.   
> 
>{ servera => ['/usr/local/bin/prog start
> databasea', '/usr/local/bin/prog start databaseb'], serverb =>
> ['/usr/local/bin/prog start database123'] }
> 
> I tried various iterations of .each to try to create and fill the array
> pointed to by the hash, but Puppet doesn't permit that as it would be
> changing an already assigned variable / hash. 
> 
> I was able use the $my_subst variable in an erb template to create the
> start/stop lines.  It worked ok for the 3 line example above, but when I
> got to dozens of servers / start lines being applied to hundreds of
> servers on each check-in it soon killed the CPU in my master server as
> it ran through a loop checking if $hostname == servername. 
> 
> Is it possible to have Puppet handle parsing the data in $my_substr, or
> even right from the raw file data to do the following? 
>1. Run through incoming data to fill start command array.
>   ['/usr/local/bin/prog start databasea', '/usr/local/bin/prog start
> databaseb']
>2. Assign that to the array of key-pairs.  { servera =>
> ['/usr/local/bin/prog start databasea', '/usr/local/bin/prog start
> databaseb'], serverb => ['/usr/local/bin/prog start database123'] }
> 
> Thanks! 
> 

Hi James,

One approach would be to not do it within a puppet manifest and instead
transform that data with a language you are familiar with and have it
write to its own file in Hiera as YAML or JSON. Once the data structure
is there, you can use the create_resources() function to create the
resources from the data in Hiera.

Another approach would be to write a custom function or ENC that uses
your CSV as the data store and for a given server respond with the start
command. If you are not familiar with ruby, the custom ENC would be
easier, since it can be in any language.

Instead of a CSV, you might want to look at Consul which can host
key/value pairs for you. You can then query it to see which databases
are associated with a given server.

Best regards,
-g

-- 
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

-- 
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/fd4a21e3-1820-ace5-36f9-407a5d980c20%40garretthoneycutt.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] How to read in file into array of hashes to use build start script template

2017-01-13 Thread James Perry
After spending most of they day digging around and researching, I find 
Puppet's immutable variables are keeping me from properly handling what I'm 
trying to do, so I want to see if anyone else has some suggestions on how 
to handle was I need to accomplish.

Goal: Ingest a CSV file provided by a user and generate a start / stop 
script, dynamically, for every server in scope, based on CSV file. 

CSV Format: 
SERVER,start command 

Example. 
SERVERA, /usr/local/bin/prog start databasea
SERVERA, /usr/local/bin/prog start databaseb
SERVER1, /usr/local/bin/prog start database123


The basic design I had in mind for the manifest is to: 
1. Read in the file as provided,
2. Convert , to downcase(A) => B
3. if $hostname == A 
   $my_server_script_lines = $my_hash[A][B]
   file { 
 ... 
 content => template("basic_start_script"),
 }

4. Create a template that runs through the $my_server_script_lines to  put 
each start line under start) and under stop) after doing a substr 
replacement of start for stop in B. 

Code so far
include stdlib
$my_data = file("/home/me/database.csv")
$my_subst = downcase(split($my_data2,'[,\n]'))
$my_hash = hash($my_subst)

notice ($my_hash[SERVERA])

$ puppet apply --verbose test.pp
Info: Loading facts
*Notice: Scope(Class[main]): '/usr/local/bin/prog start databaseb'*
Notice: Compiled catalog for myhost.net in environment production in 0.16 
seconds
Info: Applying configuration version '1484340247'
Notice: Applied catalog in 0.03 seconds

Here are the values of the variables as it processes through

$my_data = "SERVERA,/usr/local/bin/prog start databasea
SERVERA,/usr/local/bin/prog start databaseb
SERVERB,/usr/local/bin/prog start database123"

$my_subst = [servera, '/usr/local/bin/prog start databasea' , servera, 
'/usr/local/bin/prog start databaseb' , serverb, '/usr/local/bin/prog start 
database123' ]
 
$my_hash = {servera => '/usr/local/bin/prog start databaseb' , serverb => 
'/usr/local/bin/prog start database123' }

So I already know why the hash conversion dropped the "start databasea" for 
the servera key, what I can't seem to figure out is how to have it convert 
into a array of value pairs for a specific key.   

   { servera => ['/usr/local/bin/prog start 
databasea', '/usr/local/bin/prog start databaseb'], serverb => 
['/usr/local/bin/prog start database123'] }

I tried various iterations of .each to try to create and fill the array 
pointed to by the hash, but Puppet doesn't permit that as it would be 
changing an already assigned variable / hash. 

I was able use the $my_subst variable in an erb template to create the 
start/stop lines.  It worked ok for the 3 line example above, but when I 
got to dozens of servers / start lines being applied to hundreds of servers 
on each check-in it soon killed the CPU in my master server as it ran 
through a loop checking if $hostname == servername. 

Is it possible to have Puppet handle parsing the data in $my_substr, or 
even right from the raw file data to do the following? 
   1. Run through incoming data to fill start command array.   
['/usr/local/bin/prog 
start databasea', '/usr/local/bin/prog start databaseb']
   2. Assign that to the array of key-pairs.  { servera => 
['/usr/local/bin/prog start databasea', '/usr/local/bin/prog start 
databaseb'], serverb => ['/usr/local/bin/prog start database123'] }

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/4fa9b2d3-103c-413f-9be2-1f84a16c115e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Open source puppet performance monitoring/tuning?

2017-01-13 Thread Garrett Honeycutt
On 1/13/17 1:46 PM, R.I.Pienaar wrote:
> 
> 
> - Original Message -
>> From: "dkoleary" 
>> To: "puppet-users" 
>> Sent: Friday, 13 January, 2017 19:43:20
>> Subject: Re: [Puppet Users] Open source puppet performance monitoring/tuning?
> 
>> Hi, Garret;
>>
>> Your suggestion to review last_run_summary.yaml results in one huge step in
>> the right direction.
>>
>> # grep file: /opt/puppetlabs/puppet/cache/state/last_run_summary.yaml
>>  file: 121.817228425
>>
>> So, how do I go about finding out which file resource(s) are causing the
>> problem?
> 
> You can use https://github.com/ripienaar/puppet-reportprint to report on slow
> things
> 
> See the sample report.
> 
> I think it'll work with Puppet 4, it's been a while, open an issue if it 
> doesnt
> 

Thank you RI! This is really helpful and it works great with Puppet v4.

-g

-- 
Garrett Honeycutt
@learnpuppet
Puppet Training with LearnPuppet.com
Mobile: +1.206.414.8658

-- 
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/8cf0f290-fef6-368e-ee1a-25373be8ed46%40garretthoneycutt.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Open source puppet performance monitoring/tuning?

2017-01-13 Thread dkoleary
Excellent!  Thank you very much.  That will come in handy.

Doug

On Friday, January 13, 2017 at 2:06:27 PM UTC-6, R.I. Pienaar wrote:
>
>
>
> - Original Message - 
> > From: "dkoleary"  
> > To: "puppet-users"  
> > Sent: Friday, 13 January, 2017 20:52:30 
> > Subject: Re: [Puppet Users] Open source puppet performance 
> monitoring/tuning? 
>
> > Thanks; That looks like a pretty cool too; unfortunately, I can't seem 
> to 
> > get it to run. 
> > 
> > Centos 6.8 fully patched: 
> > 
> > $ ./report_print.rb 
> > ./report_print.rb:17:in `require': no such file to load -- puppet 
> > (LoadError) 
> >from ./report_print.rb:17 
>
> if you're on puppet 4 you'll need to do: 
>
>  /opt/puppetlabs/puppet/bin/ruby report_print.rb 
>
> basically you have to use the ruby that puppet uses 
>

-- 
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/9f3767a7-a1f9-4671-bf2b-c511b49078a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Open source puppet performance monitoring/tuning?

2017-01-13 Thread R.I.Pienaar


- Original Message -
> From: "dkoleary" 
> To: "puppet-users" 
> Sent: Friday, 13 January, 2017 20:52:30
> Subject: Re: [Puppet Users] Open source puppet performance monitoring/tuning?

> Thanks; That looks like a pretty cool too; unfortunately, I can't seem to
> get it to run.
> 
> Centos 6.8 fully patched:
> 
> $ ./report_print.rb
> ./report_print.rb:17:in `require': no such file to load -- puppet
> (LoadError)
>from ./report_print.rb:17

if you're on puppet 4 you'll need to do:

 /opt/puppetlabs/puppet/bin/ruby report_print.rb

basically you have to use the ruby that puppet uses

-- 
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/1449934135.1132789.1484337980731.JavaMail.zimbra%40devco.net.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] simple file resource taking longer than it should

2017-01-13 Thread dkoleary
Hi;

A follow-on to another thread; I'm trying to track down performance issues 
in open source puppet server (and clients) ver 4.5.0

Reading through last_run_summary.yaml, the vast majority of time is spent 
on file resources.  I then hit the last_run_report.yaml and, 
as an example, one of the simplest file resources took 17 seconds (assuming 
I'm reading this correctly):

  File[/etc/ntp/step-tickers]: !ruby/object:Puppet::Resource::Status
title: "/etc/ntp/step-tickers"
file: 
"/etc/puppetlabs/code/environments/dkoleary/modules/mpintp/manifests/init.pp"
line: 67
resource: File[/etc/ntp/step-tickers]
resource_type: File
containment_path:
- Stage[main]
- Mpintp
- File[/etc/ntp/step-tickers]
*evaluation_time**: 17.430422487*
tags:
- file
- class
- mpintp
- profiles::mpibase
- profiles
- mpibase
- roles::mpibase
- roles
time: '2017-01-13T13:08:38.619245800-06:00'
failed: false
changed: false
out_of_sync: false
skipped: false
change_count: 0
out_of_sync_count: 0
events: []

It'd be hard to get more simple than this file resource:

  file { '/etc/ntp/step-tickers':
ensure => 'present',
owner  => 'root',
group  => 'root',
mode   => '0644',
source => 'puppet:///modules/mpintp/step-tickers',
notify => Service['ntpd'],
  }



The rest of the module is equally as simple.  one package, one service, and 
one other file resource.  

And, of course, the performance issue is sporadic.  The very next agent run 
finished the whole thing in less than a second.  I don't believe it's a 
system resource contention.  *This* box is a linux desktop that was all but 
idle for both runs.  I'm seeing similar issues on other systems, though, so 
I'd like to be able to track this down.

Anyone have any ideas or tips on where I can look next?

Thanks for your time.

Doug O'Leary



-- 
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/582f9bae-c97d-4a83-90e8-2db2a481889d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Open source puppet performance monitoring/tuning?

2017-01-13 Thread dkoleary
Thanks; That looks like a pretty cool too; unfortunately, I can't seem to 
get it to run.  

Centos 6.8 fully patched:

$ ./report_print.rb 
./report_print.rb:17:in `require': no such file to load -- puppet 
(LoadError)
from ./report_print.rb:17

Some googling showed a 'gem install' command but that results in:

# gem install puppet
ERROR:  Error installing puppet:
puppet requires Ruby version >= 1.9.3.

Any tips?

Thanks again.

Doug O'Leary

On Friday, January 13, 2017 at 12:46:17 PM UTC-6, R.I. Pienaar wrote:
>
>
>
> - Original Message - 
> > From: "dkoleary"  
> > To: "puppet-users"  
> > Sent: Friday, 13 January, 2017 19:43:20 
> > Subject: Re: [Puppet Users] Open source puppet performance 
> monitoring/tuning? 
>
> > Hi, Garret; 
> > 
> > Your suggestion to review last_run_summary.yaml results in one huge step 
> in 
> > the right direction. 
> > 
> > # grep file: /opt/puppetlabs/puppet/cache/state/last_run_summary.yaml 
> >  file: 121.817228425 
> > 
> > So, how do I go about finding out which file resource(s) are causing the 
> > problem? 
>
> You can use https://github.com/ripienaar/puppet-reportprint to report on 
> slow 
> things 
>
> See the sample report. 
>
> I think it'll work with Puppet 4, it's been a while, open an issue if it 
> doesnt 
>

-- 
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/431839f1-39e3-4b8a-928a-1e60754b6807%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Open source puppet performance monitoring/tuning?

2017-01-13 Thread R.I.Pienaar


- Original Message -
> From: "dkoleary" 
> To: "puppet-users" 
> Sent: Friday, 13 January, 2017 19:43:20
> Subject: Re: [Puppet Users] Open source puppet performance monitoring/tuning?

> Hi, Garret;
> 
> Your suggestion to review last_run_summary.yaml results in one huge step in
> the right direction.
> 
> # grep file: /opt/puppetlabs/puppet/cache/state/last_run_summary.yaml
>  file: 121.817228425
> 
> So, how do I go about finding out which file resource(s) are causing the
> problem?

You can use https://github.com/ripienaar/puppet-reportprint to report on slow
things

See the sample report.

I think it'll work with Puppet 4, it's been a while, open an issue if it doesnt

-- 
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/380462397.1041195.1484333171651.JavaMail.zimbra%40devco.net.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Open source puppet performance monitoring/tuning?

2017-01-13 Thread dkoleary
Hi, Garret;

Your suggestion to review last_run_summary.yaml results in one huge step in 
the right direction.  

# grep file: /opt/puppetlabs/puppet/cache/state/last_run_summary.yaml
  file: 121.817228425

So, how do I go about finding out which file resource(s) are causing the 
problem?

Thanks a lot for the tip.  Appreciate it immensely.

Doug O'Leary


>

-- 
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/cceb8898-6860-41d6-8b91-30b80b6917fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Open source puppet performance monitoring/tuning?

2017-01-13 Thread dkoleary
Hey;

thanks for the reply.  I do use augeas sparsely.  Turns out that's not the 
issue but your suggestion is very intriguing.  I'm going to be trying that 
out shortly.

Thanks

Doug

>
>

-- 
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/7e865f8f-5c92-4b5f-ade9-4a4c0d1b7c7e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Debugging confusion !?

2017-01-13 Thread Steve Button
Hi,

I've been struggling to debug this Puppet code for a couple of days now. 
Perhaps it's something obvious but I just can't see it! Can anyone suggest 
a debugging approach to get this working??

Why is it complaining every time that redis and Ruby are already at the 
lastest versions?

More importantly what is the prereq failure for rvm? 

Here's the mis-behaving class :-

# Install Ruby RVM

class profile::rvm {

  $user = 'myuser'

  user {$user:} # This is needed to satisfy puppet's require in the 
single_user_rvm module.

  notify {"b4rvm":}

  single_user_rvm::install { $user: , require => Notify['b4rvm']}

  single_user_rvm::install_ruby { 'ruby-2.3.0': user => 'shazino' }

}

I only added the notify to try to help me make sense of the debug output a 
little.

usernanme@ubuntu-xenial:/vagrant/puppet$ sudo puppet apply 
--modulepath=/usr/share/puppet/modules:/vagrant/puppet:/vagrant/puppet/modules:~/.puppet/modules
 
 manifests/site.pp
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Warning: Scope(Concat[/etc/postgresql/9.5/main/pg_ident.conf]): The $force 
parameter to concat is deprecated and has no effect.
Notice: Compiled catalog for ubuntu-xenial.localdomain in environment 
production in 4.73 seconds
Notice: b4rvm
Notice: /Stage[main]/Profile::Rvm/Notify[b4rvm]/message: defined 'message' 
as 'b4rvm'
Error: Execution of '/usr/bin/apt-get -q -y -o 
DPkg::Options::=--force-confold install redis-server' returned 100: Reading 
package lists...
Building dependency tree...
Reading state information...
redis-server is already the newest version (2:3.0.6-1).
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up redis-server (2:3.0.6-1) ...
adduser: The user `redis' already exists. Exiting.
insserv: script redis-server: service redis-server already provided!
insserv: exiting now!
update-rc.d: error: insserv rejected the script header
dpkg: error processing package redis-server (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 redis-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Error: /Stage[main]/Redis::Install/Package[redis-server]/ensure: change 
from absent to present failed: Execution of '/usr/bin/apt-get -q -y -o 
DPkg::Options::=--force-confold install redis-server' returned 100: Reading 
package lists...
Building dependency tree...
Reading state information...
redis-server is already the newest version (2:3.0.6-1).
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up redis-server (2:3.0.6-1) ...
adduser: The user `redis' already exists. Exiting.
insserv: script redis-server: service redis-server already provided!
insserv: exiting now!
update-rc.d: error: insserv rejected the script header
dpkg: error processing package redis-server (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 redis-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Error: Execution of '/usr/bin/apt-get -q -y -o 
DPkg::Options::=--force-confold install rubygems' returned 100: Reading 
package lists...
Building dependency tree...
Reading state information...
ruby is already the newest version (1:2.3.0+1).
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up redis-server (2:3.0.6-1) ...
adduser: The user `redis' already exists. Exiting.
insserv: script redis-server: service redis-server already provided!
insserv: exiting now!
update-rc.d: error: insserv rejected the script header
dpkg: error processing package redis-server (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 redis-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
Error: /Stage[main]/Ruby/Package[rubygems]/ensure: change from purged to 
present failed: Execution of '/usr/bin/apt-get -q -y -o 
DPkg::Options::=--force-confold install rubygems' returned 100: Reading 
package lists...
Building dependency tree...
Reading state information...
ruby is already the newest version (1:2.3.0+1).
0 upgraded, 0 newly installed, 0 to remove and 64 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up redis-server (2:3.0.6-1) ...
adduser: The user `redis' already exists. Exiting.
insserv: script redis-server: service redis-server already provided!
insserv: exiting now!
update-rc.d: error: insserv rejected the script header
dpkg: error processing package redis-server (--configure):
 subprocess installed post-installation script returned 

[Puppet Users] How to reference NFS shares in a file resource

2017-01-13 Thread warron.french
Hi, I need to understand how to properly write some puppet code that will
take files off of an NFS share on serverA and place them on my clients via
a puppet module.

My NFS server is *serverA.home*, providing serverA:/some/path that mounts
on my clients
my puppet master is *puppetmaster.home*,

I believe (please correct me) that I can create a puppet file resource and
then use the attribute called *source*.

I don't know how to properly implement the source attribute with respect to
my nfs server *serverA.home*.  Does the NFS mount need to be on the client
machines, or available to the *puppetmaster.home* host?



Thanks to anyone who can help me with this.
--
Warron French

-- 
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/CAJdJdQmAO%2BPFOpqDPaEgJ_Q0uKcBD9iuW266wu4pLmpRNadakQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Weird behavior of puppetdb records

2017-01-13 Thread Maksim Podlesniy
We have an issue with virtual resources. Usual during puppet applying 
inside puppetdb appears additional node record which leads to puppet 
duplicate error

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
A duplicate resource was found while collecting exported resources, with 
the type and title Exec[check context8 ctxtmongod-shard8-1.aws:31008] on 
node ctxtmongod-shard8-1.aws

There are two records inside puppetdb which appears right after first 
puppet agent applying

[puppet3 ~]$ curl -s0 -X GET 
'http://localhost:8080/v3/nodes/ctxtmongod-shard8-1.aws' 
{
  "name" : "ctxtmongod-shard8-1.aws",
  "deactivated" : null,
  "catalog_timestamp" : "2017-01-13T12:09:30.779Z",
  "facts_timestamp" : "2017-01-13T12:10:33.106Z",
  "report_timestamp" : "2017-01-13T12:10:14.489Z"
}

[puppet3 ~]$ curl -s0 -X GET 
'http://localhost:8080/v3/nodes/ctxtmongod-shard8-1.aws.example.net' 
{
  "name" : "ctxtmongod-shard8-1.aws.example.net",
  "deactivated" : null,
  "catalog_timestamp" : "2016-03-01T13:56:15.086Z",
  "facts_timestamp" : "2017-01-13T12:10:51.026Z",
  "report_timestamp" : null
}

If we deactivate this records inside puppetdb then they will appear after 
second applying (ctxtmongod-shard8-1.aws after first and 
ctxtmongod-shard8-1.aws.example.net 
after second)
puppet applying can run only in first time after deactivation both puppetdb 
records

Puppet version is 3.8.7. But we had few major updates

May be somebody knows what is happening

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/b7315a7d-e707-4466-a86b-156af66db9e6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-13 Thread Rob Nelson
There's also `last reboot -1`, add your favorite timestamp format with -T :)


Rob Nelson
rnels...@gmail.com

On Fri, Jan 13, 2017 at 6:27 AM, Thomas Müller 
wrote:

>
>
> Am Dienstag, 10. Januar 2017 17:44:23 UTC+1 schrieb Denny:
>>
>> Hi there,
>>
>> probably a pretty easy to answer question.
>>
>> I want to try out adding custom facts. My first custom fact should be
>> "lastrebootdate"
>>
>> My code looks like this:
>>
>> Facter.add(:lastrebootdate) do
>>   setcode do
>> Facter::Util::Resolution.exec("/usr/bin/who -b |awk '{print $3}'")
>>   end
>> end
>>
>> Running the command on the system returns "2017-01-30"
>>
>>
>>
> just a random thought: instead of calling who you could take the already
> existing uptime fact and just calculate the date with ruby time/date
> functions.
>
> - Thomas
>
>
> --
> 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/41898ce0-c5e3-472f-98f9-eb4fbae47aa8%40googlegroups.com
> 
> .
> For more options, visit 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/CAC76iT9-egYN4OeKg9qk%3DrwxMhRPgON-UMxyPRKvZJPvt%3DikVg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Regex auto-escape

2017-01-13 Thread Ugo Bellavance


On Friday, January 13, 2017 at 6:24:57 AM UTC-5, Thomas Müller wrote:
>
>
>
> Am Donnerstag, 12. Januar 2017 20:23:48 UTC+1 schrieb Ugo Bellavance:
>>
>> Hi,
>>
>> I've been working on a public module that manage text entries that have 
>> SELinux contexts in them. I added basic support to some of the regex 
>> special characters that may be used in SELinux contexts and here's the 
>> result: 
>> https://github.com/ubellavance/puppet-selinux/blob/deleteworks/manifests/fcontext.pp#L49-L50.
>>  
>>  After having done something that fits my need up to now, I knew that it 
>> was probably not perfect so I looked at some lists of contexts and found 
>> out that there are a lot more than just "(/.*)" entries but I think it 
>> doesn't make sense to do a regsubst for every special character.  Is there 
>> something that can be done directly in the module that would automatically 
>> put a backspace before every regex special character?
>>
>>  
> maybe the shellwords does it for you: 
> http://ruby-doc.org/stdlib-2.0.0/libdoc/shellwords/rdoc/Shellwords.html
>
>  
> instead of working on your own selinux module I'd invite you to 
> parcitipate on the voxpupuli/selinux module: 
> https://github.com/voxpupuli/puppet-selinux
>
 
Thanks for your answer. The selinux module is actually from camptocamp. 
Mine is a fork, but you're right, I should test voxpopuli'.  At the time at 
which I needed an SELinux module, I needed SELinux ports support, which, I 
think, wasn't supported by voxpopul's (or its ancestor), so I chose 
camptocamp's. I realize that I "lost" many hours to improve camptocamp's 
module while a switch to voxpopuli was the right thing to do.  At least it 
gave me more experience with contributing to puppet modules.  camptocamp's 
module is simpler than voxpopuli, so it's more accessible to me.

Now I have some testing to do :).

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/981fcd68-02d2-46e4-9fa0-80ebc9dbf67a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: writing custom fact -> return value not as expected

2017-01-13 Thread Thomas Müller


Am Dienstag, 10. Januar 2017 17:44:23 UTC+1 schrieb Denny:
>
> Hi there,
>
> probably a pretty easy to answer question.
>
> I want to try out adding custom facts. My first custom fact should be 
> "lastrebootdate"
>
> My code looks like this:
>
> Facter.add(:lastrebootdate) do
>   setcode do
> Facter::Util::Resolution.exec("/usr/bin/who -b |awk '{print $3}'")
>   end
> end
>
> Running the command on the system returns "2017-01-30"
>
>
>
just a random thought: instead of calling who you could take the already 
existing uptime fact and just calculate the date with ruby time/date 
functions.

- Thomas
 

-- 
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/41898ce0-c5e3-472f-98f9-eb4fbae47aa8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Regex auto-escape

2017-01-13 Thread Thomas Müller


Am Donnerstag, 12. Januar 2017 20:23:48 UTC+1 schrieb Ugo Bellavance:
>
> Hi,
>
> I've been working on a public module that manage text entries that have 
> SELinux contexts in them. I added basic support to some of the regex 
> special characters that may be used in SELinux contexts and here's the 
> result: 
> https://github.com/ubellavance/puppet-selinux/blob/deleteworks/manifests/fcontext.pp#L49-L50.
>  
>  After having done something that fits my need up to now, I knew that it 
> was probably not perfect so I looked at some lists of contexts and found 
> out that there are a lot more than just "(/.*)" entries but I think it 
> doesn't make sense to do a regsubst for every special character.  Is there 
> something that can be done directly in the module that would automatically 
> put a backspace before every regex special character?
>
>  
maybe the shellwords does it for you: 
http://ruby-doc.org/stdlib-2.0.0/libdoc/shellwords/rdoc/Shellwords.html

 
instead of working on your own selinux module I'd invite you to parcitipate 
on the voxpupuli/selinux module: https://github.com/voxpupuli/puppet-selinux

- Thomas

-- 
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/03155d97-3b6e-4ba4-9d3b-bd0fc7beaf18%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Trouble using type Stdlib::Windowspath

2017-01-13 Thread Tiago Delboni
Em quarta-feira, 11 de janeiro de 2017 15:38:28 UTC-2, Henrik Lindberg 
escreveu:
>
>
> Maybe there is something wrong with that type. 
> What does this give you: 
>
> notice('C:\a\valid\path' =~ Stdlib::Windowspath) 
>
> If that fails, please report the issue against stdlib. 
> (Or I am blind and there is something not right about the path). 
>
>
Hi Henrik

The first notice bellow returns FALSE and the second, that uses 
Stdlib::Windowspath definition from "puppetlabs-stdlib\types\windowspath.pp" 
returns TRUE.

notice('C:\temp' =~ Stdlib::Windowspath)  

notice('C:\temp' =~ 
Pattern[/^(([a-zA-Z]:[\\\/])|([\\\/][\\\/][^\\\/]+[\\\/][^\\\/]+)|([\\\/][\\\/]\?[\\\/][^\\\/]+))/])

I also defined my own Windowspath type in "mymodule\types\windowspath.pp" 
and the following test returns FALSE:

notice('C:\temp' =~ Mymodule::Windowspath)  

I guess it all points to a "type loading" issue - I can't use types, even 
those defined inside my own module. :(




>

-- 
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/beb5380e-76a4-41b3-bf8b-1b3b2f825665%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Puppet Language Style Guide update

2017-01-13 Thread Henrik Lindberg

On 13/01/17 08:38, Peter Faller wrote:

Has the Gepetto auto-formatter been updated (or will it be updated) to
match the style guide? Or is there another way of automatically
formatting manifests to match the style guide?



Geppetto is pretty much up to date on the style guide as there are no 
fundamental changes to the formatting in terms of indentation and 
spacing. It is however somewhat behind on the language support as it has 
no understanding of the type system and some other recent additions.
Geppetto is no longer maintained by Puppet as announced quite a long 
time ago.


An IDE that has recently updated their support for Puppet is RubyMine. 
It is well worth taking a look at. Don't know what kind of formatting 
they offer though.


Best,
- henrik




--
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/d36a42d7-d46e-4cc5-b198-8b7b396031e3%40googlegroups.com
.
For more options, visit https://groups.google.com/d/optout.



--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

--
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/8c548bcc-1540-7d87-d2d3-ef92ba1c554d%40puppet.com.
For more options, visit https://groups.google.com/d/optout.