[Puppet Users] Re: New to puppet

2014-10-09 Thread Krishna Krishna
John,

thanks for your response. 

I am planning to take Puppet 202. I think that the entry level exam.

Which has some background of the software and some labs.

As of now I am kinda shooting in dark. However when I start my 
certification I will have more specific questions.

To give you more insight in what I am after. 

- I am planning to divert my career towards data center
- Puppet and Cisco data center technology is two courses I am aiming for

Any comments will be appriciated.

On Thursday, 9 October 2014 00:36:13 UTC+11, jcbollinger wrote:
>
>
>
> On Wednesday, October 8, 2014 1:15:29 AM UTC-5, Krishna Krishna wrote:
>>
>> Ok,
>>
>> I am newbie to puppet. So be nice. I may ask some stupid questions.
>>
>> I could not find some similar post so creating new post.
>>
>> I have not worked on puppet before except of downloading puppet on my 
>> linux machine and playing with some commands just to get feel of it. I do 
>> not work on Linux either but I do have fair background of linux.
>>
>> I am planning to give puppet certification in 2-3 months. Below are some 
>> quesitons which I have.
>>
>> What type of hardware do I need ? (I only have one laptop, I can use 
>> virtual box and fire couple of more systems), Should that be enough ? 
>>
>
>
> You should have at least two machines, whether physical or virtual.  More 
> machines would allow you to explore marginally more Puppet features, but 
> are probably not necessayr.
>
>  
>
>> I do believe I can download puppet version for free and use it to manage 
>> 10 nodes but does it come with all require components?
>>
>
>
> I don't know what certification you are planning to take.  If it is 
> specific to Puppet Enterprise, then be aware that PE comes packaged with 
> all Puppet system components and a Ruby runtime to run them in, but the 
> system does rely on you to provide a suitable OS and general operating 
> environment.
>
> The open source version of Puppet has fewer built in bells and whistles, 
> but if that's all your certification is going to cover then you should not 
> spend effort learning all the PE stuff.  Open source Puppet does not come 
> packaged with a Ruby runtime, or various other generic components, but 
> PuppetLabs does offer it in the form of packages for various operating 
> systems that will help you install the needed third-party components.
>
>  
>
>> Is exam based on MCQ's ? 
>>
>
>
> You should consult the documentation of the exam.
>
>  
>
>> What is passing score ? 
>>
>
>
> You should consult the documentation of the exam, but what does it matter, 
> anyway?  You learn the material as well as you can; you take the exam; you 
> pass if you learned well enough, else not.
>
>
> Any other information I should know ?
>>
>
>
> Generally speaking?  Far more than I could possibly convey in this venue.  
> If you want a useful answer, you'll need to pose a more specific question.
>
>
> John
>
>

-- 
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/f47309ce-c11a-41cf-8268-9827dba6278b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] puppetdb export - WTF?!

2014-10-09 Thread JonY
Update: 45 hours - ~75% complete

On Tuesday, October 7, 2014 1:32:02 PM UTC-7, JonY wrote:
>
> Running for 7 hours now. Has exported ~15-20% of the data.
>
> I'm intrigued to see what I end up with.
>
>
> On Tuesday, October 7, 2014 1:19:04 PM UTC-7, Wyatt Alt wrote:
>>
>> Thanks Jony.
>>
>> I've loaded up an embedded database to comparable capacity and while 
>> export isn't quick, it's not nearly as slow as you're experiencing.
>>
>> Fro your process list the PDB appears to be running with a max heap size 
>> (Xmx) of 1024m.  Perhaps increasing this could make a difference?
>>
>> The export process appears to be using 192m, but I think that should be 
>> using the same JAVA_ARGS as PuppetDB itself and so could be a bug.
>>
>> Wyatt
>>
>>
>> On Tue, Oct 7, 2014 at 11:03 AM, JonY  wrote:
>>
>>> https://gist.github.com/ce60c590a0531c0b09cd.git
>>>
>>>
>>> # rpm -qa | grep puppet
>>> puppet-server-3.7.1-1.el6.noarch
>>> puppetlabs-release-6-11.noarch
>>> puppetdb-terminus-2.2.0-1.el6.noarch
>>> puppet-3.7.1-1.el6.noarch
>>> vim-puppet-2.7.20-1.el6.rf.noarch
>>> puppetdb-2.2.0-1.el6.noarch
>>>
>>> Am storing 30 days of data. Yes - it's a fair bit more then the default.
>>>
>>>
>>>
>>>
>>> On Tuesday, October 7, 2014 9:00:17 AM UTC-7, Wyatt Alt wrote:

 Hey JonY,

 Sounds interesting.  What version of PuppetDB are you using?  Do you 
 have reports, facts, and catalogs, or only some of those? Can you paste 
 your config.ini?

 Also can you give the output of

 ps aux |grep java
 top -n1
 free

 in a gist maybe?

 Wyatt





 On Tue, Oct 7, 2014 at 8:30 AM, JonY  wrote:

> (ok - terrribly unprofessional title.. I get it).
>
> I'm trying to 'do the right thing' and move from the embedded DB to 
> Postgres. Following the instructions I figured I would dump out the 
> contents of the embedded DB and import this into Postgres.
>
> So I start 'puppetdb export --outfile '. 
>
> Pour some coffee.
>
> Watch it dump one node.
>
> Have some more coffee.
>
> Wait.
>
> One more node.
>
> Hours pass. Glaciers melt. 
>
> 3+ hours into the process and it has dumped 10 nodes (of > 100). At 
> this rate I'm looking at about 1.5 days to get this done. Really? 
>
> System has 16 cores, 32Gb of RAM.. barely running at idle. Tell me I 
> missed some critical parameter.
>
>
>  -- 
> 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.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-users/1fbe251a-2c25-42ea-9529-d01bbf561980%
> 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...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/puppet-users/9b735460-1722-48dc-9ad5-f34f554567f4%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/b0bd8590-0649-4188-a325-fe41168f96bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Kai Timmer
Hello,
I'm using this snippet to build my icinga configuration out of my exported 
facts

  #Collect the nagios_host resources
  Nagios_host <<||>> {
target  => "/etc/icinga/puppet.d/hosts.cfg",
require => File["/etc/icinga/puppet.d/hosts.cfg"],
notify => Service[icinga],
  }

If I now deactivate a host on my puppetdb with:

puppet node deactivate fqdn.of.host

I would assume that on the next run my hosts.cfg should be without the 
deactivated host. But this doesn't work. The host stays in the file. I can 
only remove it, if I delete the hosts.cfg file and than let puppet run 
again.
Did I miss something or is it not possible to automatically remove the host?

-- 
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/d2c05cf4-3eb1-4619-a97d-e2d16e3822cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Ken Barber
> I'm using this snippet to build my icinga configuration out of my exported
> facts
>
>   #Collect the nagios_host resources
>   Nagios_host <<||>> {
> target  => "/etc/icinga/puppet.d/hosts.cfg",
> require => File["/etc/icinga/puppet.d/hosts.cfg"],
> notify => Service[icinga],
>   }
>
> If I now deactivate a host on my puppetdb with:
>
> puppet node deactivate fqdn.of.host
>
> I would assume that on the next run my hosts.cfg should be without the
> deactivated host. But this doesn't work. The host stays in the file. I can
> only remove it, if I delete the hosts.cfg file and than let puppet run
> again.
> Did I miss something or is it not possible to automatically remove the host?

Nope it should work in theory, are you using PuppetDB for this? If so
in the puppetdb.log you should see a corresponding log entry for the
deactivate command for that node. Can you grep against your
puppetdb.log to see if this arrives when you send the `puppet node
deactivate {foo}` command.

Also check to make sure no new commands have come in for that node, it
will tell you in the log if this has happened. We reactivate a node on
any new data, so this is worth checking.

After deactivation you should be able to query the node data with
something like:

curl 'http://localhost:8080/v3/nodes/node_name'

And you should see a date next to 'deactivated' that indicates when it
was deactivated. If its deactivated then it should not collect.

Finally, try using a tool like this to analyze what exports still exist:

https://forge.puppetlabs.com/zack/exports

This will help you understand if the node you are trying to deactivate
is still exporting this data, or if its coming from another place.
This is important, sometimes there is data coming from another node,
and its often what users don't expect. Make sure you check for typos
on the node name most importantly, this is the biggest contributing
factor to confusion around this :-).

ken.

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


Re: [Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Kai Timmer


Am Donnerstag, 9. Oktober 2014 14:10:49 UTC+2 schrieb Ken Barber:
>
> Nope it should work in theory, are you using PuppetDB for this? If so 
> in the puppetdb.log you should see a corresponding log entry for the 
> deactivate command for that node. Can you grep against your 
> puppetdb.log to see if this arrives when you send the `puppet node 
> deactivate {foo}` command.
>

Yes, I'm using puppetdb and the command arrives at the database:
2014-10-09 13:31:37,302 INFO  [c.p.p.command] 
[55a70ff1-3491-4885-9614-589b35756883] [deactivate node] fqdn.of.host
 

> Also check to make sure no new commands have come in for that node, it 
> will tell you in the log if this has happened. We reactivate a node on 
> any new data, so this is worth checking. 
>
> After deactivation you should be able to query the node data with 
> something like: 
>
> curl 'http://localhost:8080/v3/nodes/node_name' 
>
> And you should see a date next to 'deactivated' that indicates when it 
> was deactivated. If its deactivated then it should not collect. 
>

This should output the same as puppet node status fqdn.of.host, right?

fqdn.of.host
Deactivated at 2014-10-09T11:31:37.300Z
Last catalog: 2014-10-07T15:11:36.671Z
Last facts: 2014-10-07T15:11:34.151Z


What caught my attention here is that the Timestamp here is different from 
the timestamp in the log. Maybe the is something going wrong there? 
PuppetDB and Puppetmaster are running on the same host, so there should be 
no time difference.
 

> Finally, try using a tool like this to analyze what exports still exist: 
>
> https://forge.puppetlabs.com/zack/exports 
> 
>  
>
> This will help you understand if the node you are trying to deactivate 
> is still exporting this data, or if its coming from another place. 
> This is important, sometimes there is data coming from another node, 
> and its often what users don't expect. Make sure you check for typos 
> on the node name most importantly, this is the biggest contributing 
> factor to confusion around this :-). 


The node doesn't show up with puppet node exports
But a puppet agent -t run on the icinga node still doesn't remove the node.

Maybe I should say that I am using foreman. But I also deactivated the node 
in foreman. So my guess is that I'm good there.

Best regards,
Kai

-- 
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/bf7089a7-ba2d-4978-aa3e-a8b273cb11c5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Ken Barber
>> Nope it should work in theory, are you using PuppetDB for this? If so
>> in the puppetdb.log you should see a corresponding log entry for the
>> deactivate command for that node. Can you grep against your
>> puppetdb.log to see if this arrives when you send the `puppet node
>> deactivate {foo}` command.
>
>
> Yes, I'm using puppetdb and the command arrives at the database:
> 2014-10-09 13:31:37,302 INFO  [c.p.p.command]
> [55a70ff1-3491-4885-9614-589b35756883] [deactivate node] fqdn.of.host

Good.

> What caught my attention here is that the Timestamp here is different from
> the timestamp in the log. Maybe the is something going wrong there? PuppetDB
> and Puppetmaster are running on the same host, so there should be no time
> difference.

The timestamp is in ISO-8601 format, which means its got a timezone
associated with it, in this case UTC. Could this be the cause of
confusion?

>> Finally, try using a tool like this to analyze what exports still exist:
>>
>> https://forge.puppetlabs.com/zack/exports
>>
>> This will help you understand if the node you are trying to deactivate
>> is still exporting this data, or if its coming from another place.
>> This is important, sometimes there is data coming from another node,
>> and its often what users don't expect. Make sure you check for typos
>> on the node name most importantly, this is the biggest contributing
>> factor to confusion around this :-).
>
>
> The node doesn't show up with puppet node exports
> But a puppet agent -t run on the icinga node still doesn't remove the node.
>
> Maybe I should say that I am using foreman. But I also deactivated the node
> in foreman. So my guess is that I'm good there.

Wait, are you actually purging the resources somewhere? If it becomes
unmanaged, that doesn't mean it cleans up after itself unless you are
purging also.

ken.

-- 
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/CAE4bNT%3DpAnOoPp5LrSfuojGzO4bDYxSscpks3-PZHFHTi6T9fw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Kai Timmer
2014-10-09 14:56 GMT+02:00 Ken Barber :

> Wait, are you actually purging the resources somewhere? If it becomes
> unmanaged, that doesn't mean it cleans up after itself unless you are
> purging also.
>

I did this:
[image: Inline-Bild 1]

Not sure if I can follow you though?!

What happens if I manually add a (fake) host to my hosts.cfg file. The host
doesn't exist in the puppetdb, because it was never "alive". On the next
puppet run, puppet should remove this "false" entry in my hosts.cfg, right?

Best Regards,
-- Kai Timmer / em...@kaitimmer.de

-- 
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/CA%2B0qVEdODowz61qadUpX%3DSNy-84pWgkKicbM66Mjg_8fPYFU_g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: stdlib keys()

2014-10-09 Thread jcbollinger


On Wednesday, October 8, 2014 2:15:09 PM UTC-5, Juan Andres Ramirez wrote:
>
> Thank you very much Felix for you replay.
> I got it now , but I have an other question:
>
> I created file findarray.pp with this code inside:
> define findarray(
>$sitearray = $title,
>$siteName
> ){
>   notify{"ARRAY DEL SITIO - ${sitearray}":}
> }
>
> and call findarray from init.pp, with next code:
> $site_array = hiera("host_key")
> $prueba = keys($site_array)
>
> findarray{$prueba:
>siteName => $siteName
> }
>
> this code return only ARRAY DEL SITIO - server1 and ARRAY DEL SITIO - 
> server2.
> How to get all data from hiera, why only get server1 and server2 and no 
> other data?.
>
>

Why do you expect to get anything else?  The keys are the only part of your 
data that you give to your Findarray instances.

If you have hiera data containing a hash mapping resource names to property 
hashes, then you have two pretty straightforward ways to declare the 
resources thereby described:

1. You can use create_resources() 
.
  
The data structure you already have is perfectly set up for that.  I'm OK 
with create_resources(), but I tend to prefer more "hands-on" approaches.  
In particular,

2. If your resources are of a defined type, then you can also do something 
along these lines:

class my_module {
  $hosts = hiera('host_key', [])
  my_module::my_host { $hosts:  }
}

define my_module::my_host () {
  $my_host_data = $::my_module::hosts[$title]
  notify { "$title alias: ${my_host_data['alias']}": }
  notify { "$title IP address: ${my_host_data['ipaddress']}": }
  notify { "$title port: ${my_host_data['port']}": }
}

Another variation on that passes the whole hash as a parameter to the 
defined type:

define my_module::my_host_v2 ($all_hosts_data) {
  $my_host_data = $all_hosts_data[$title]
  # ...
}


John

-- 
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/41635036-6bfc-4ccf-b930-08eda16b0a6a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Ken Barber
>> Wait, are you actually purging the resources somewhere? If it becomes
>> unmanaged, that doesn't mean it cleans up after itself unless you are
>> purging also.
>
>
> I did this:
>
> Not sure if I can follow you though?!
>
> What happens if I manually add a (fake) host to my hosts.cfg file. The host 
> doesn't exist in the puppetdb, because it was never "alive". On the next 
> puppet run, puppet should remove this "false" entry in my hosts.cfg, right?

No not necessarily, you need to enable resource purging with resources
like nagios_host:

resources { "nagios_host":
  purge => true,
}

ken.

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


[Puppet Users] Re: how to execute paths in a text file in puppet ruby

2014-10-09 Thread Spriya
Hi,

When i executed your facts. It is throwing me error

 *irb*
*irb(main):001:0> require 'facter'*
*=> true*
*irb(main):002:0> Facter.add(:java_versions1) do*
*irb(main):003:1* setcode do*
*irb(main):004:2*  file = '/home/suppalapati/java.txt'*
*irb(main):005:2> if File.exists?('/home/suppalapati/java.txt')*
*irb(main):006:3> lines = File.readlines( file, "\n")*
*irb(main):007:3>  if ! lines.nil?*
*irb(main):008:4> versions = lines.collect {|command| `#{command.chop}`}*
*irb(main):009:4> else*
*irb(main):010:4*  versions = `java -version`.to_a*
*irb(main):011:4> end*
*irb(main):012:3> versions.join(",")*
*irb(main):013:3>  else*
*irb(main):014:3* versions = "Can't find file: #{file}"*
*irb(main):015:3>  end*
*irb(main):016:2>  end*
*irb(main):017:1>  end*
*=> #*


*Please help me*


On Wednesday, October 8, 2014 5:08:28 PM UTC-4, Corey Osman wrote:
>
> Yea looks like the Facter readlines method doesn't exist.
>
> http://ruby-doc.org/core-1.8.7/IO.html#method-c-readlines
>
> You will need to use ruby's readlines and probably clean up the lines as 
> well with chop.
>
> Revised edition:  (untested, and probably full of syntax errors)
>
> Facter.add(:java_versions1) do
>  setcode do
> file = '/home/suppalapati/java.txt'
> if File.exists?('/home/suppalapati/java.txt')
>lines = File.readlines( file, "\n")
>if ! lines.nil?
>  versions = lines.collect {|command| `#{command.chop}`}
>else
>  versions = `java -version`.to_a
>   end
>   versions.join(",")
>else
>  # poor mans debugger
>  versions = "Can't find file: #{file}"
> end
>
>  end
> end
>
> Please read : https://docs.puppetlabs.com/facter/1.7/custom_facts.html
>
> See section about loading custom facts. This will give you the chance to 
> test on your machine.  
>
> check syntax ruby -c  
> On Wednesday, October 8, 2014 12:33:55 PM UTC-7, Spriya wrote:
>>
>> Hi,
>>
>> I used the same command which you provided me
>>
>> Here is the code:
>>
>> Facter.add(:java_versions1) do
>>  setcode do
>> log = Facter::Util::FileRead.readlines( 
>> '/home/suppalapati/java.txt')
>> if ! log.nil?
>>versions = log.collect {|command| `#{command}`}
>> else
>>versions = `java -version`.to_a
>> end
>> versions.join(",")
>>  end
>> end
>>
>>
>> Here is my txt file
>> /usr/java/jre1.7.0_51/bin/java
>> /usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/bin/java
>>
>> /opt/CLM-Web-Tools/im/linux.gtk.x86_64/jre_6.0.0.sr9_20110208_03/jre/bin/java
>> /opt/CLM-Web-Tools/im/linux.gtk.x86/jre_6.0.0.sr9_20110208_03/jre/bin/java
>> /opt/IBM/TeamConcertBuild/jre/bin/java
>>
>> /opt/IBM/InstallationManager/eclipse/jre_6.0.0.sr9_20110208_03/jre/bin/java
>>
>> /opt/IBM/InstallationManager_old/InstallationManager_old/eclipse/jre_6.0.0.sr9_20110208_03/jre/bin/java
>> /opt/IBM/TeamConcertBuild_old/jre/bin/java
>> /opt/itm/v6.2.2/JRE/lx8266/bin/java
>> /var/lib/alternatives/java
>> /u01/app/oracle/product/jdk1.7.0_25/jre/bin/java
>> /u01/app/oracle/product/jdk1.7.0_25/bin/java
>>
>> The fact is not returning anything.
>>
>> Let me know
>>
>> On Wednesday, October 8, 2014 3:22:22 PM UTC-4, Corey Osman wrote:
>>>
>>>
>>>
>>> *I would probably do something like this where we store all the java 
>>> versions in a comma separated string.Although if using facter >= 2.0 you 
>>> can probably remove the join statement and store as an array.I also want to 
>>> point out that java -version returns about 3 lines of text which may not be 
>>> desirable. I am also not sure if Facter has a readlines  method (guessing 
>>> it does), so you might have to swap out with ruby's file reading code.*
>>>
>>> Facter.add(:java_versions) do
>>>  setcode do
>>> log = 
>>> Facter::Util::FileRead.readlines( '/home/weblogic/java.txt')
>>>
>>> *if ! log.nil?   versions = log.collect {|command| 
>>> `#{command}`}else   versions = `java -version`.to_a*
>>> *end versions.join(",") end*
>>> end
>>>
>>>
>>> Corey
>>>
>>> On Tuesday, October 7, 2014 10:31:12 AM UTC-7, Spriya wrote:

 Hi,

 I have a text file where i get all the java version.

 *cat java.txt*
 */usr/lib/jvm/java-1.7.0-openjdk-1.7.0.65.x86_64/jre/bin/java -version*
 */usr/lib/jvm/java-1.6.0-openjdk-1.6.0.0.x86_64/jre/bin/java -version*
 */opt/oracle/agent12c/core/12.1.0.4.0/jdk/bin/java -version*
 */opt/oracle/agent12c/core/12.1.0.4.0/jdk/jre/bin/java -version*
 */var/lib/alternatives/java -version*
 */u01/java/jdk1.7.0_65/jre/bin/java -version*
 */u01/java/jdk1.7.0_65/bin/java -version*


 Now i want to run commands in each line and place it in facts.

 How can i do that.

 I have just started doing the code*.*







 *logfile = '/home/weblogic/java.

[Puppet Users] Re: How to ensure a variable gets set, before a File or Service gets set.

2014-10-09 Thread Grant Schoep


On Wednesday, October 8, 2014 7:20:52 AM UTC-6, jcbollinger wrote:
>
>
>
> On Tuesday, October 7, 2014 9:20:41 AM UTC-5, Grant Schoep wrote:
>>
>> So I have the following puppet rule. Pasted below. The problem is, 
>> sometimes, I see it looks like it is running the File before it sets the 
>> variable $sendmail_file in the case statement above. The reason I believe 
>> this, is because of the error message that it reports. Which is
>>
>> Error Message:
>> err: /File[sendmailcf]/ensure: change from absent to file failed: Could 
>> not set 'file on ensure: No such file or directory - 
>> /etc/mail/sendmail.cf.puppettmp_6850 at 
>> /etc/puppet/modules/sendmail/manifests/client.pp:40
>>
>> What I can't figure out, is how to ensure that that variable gets set, 
>> before it gets used. Any pointers?
>>
>
>
> Puppet evaluates the class body in order, left-to-right, top-to-bottom, so 
> I think your hypothesis is mistaken.  Moreover, your error message does not 
> seem to agree with your hypothesis: it is about a *local* file on the 
> node, whereas the only variable in your class controls which 'source' file 
> to use on the master.  (The same principle is in operation even if you're 
> running in masterless mode.)
>
> It looks like Puppet wants to update your sendmail.cf.  In standard 
> fashion, it tries to create the new version as a temp file first, which (if 
> all goes well) it will later move to replace the original file.  It is 
> unable to create the temp file, however, or else something prevents access 
> to it or removes it again immediately after it is created.  Perhaps your 
> disk is full, but more likely some form of access control is getting in 
> Puppet's way.
>
>
> John
>
>
Ah, you are right, I was thinking "too complicated"  The dependency I was 
missing was the sendmail package, which created the /etc/mail/ directory.   
I was thrown off by the "puppettmp_6850" name, thinking that was "junk" 
from an uninitialized variable.


-- 
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/5bcc3b2e-175a-46ba-a49a-033e7b1c543e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Need help with simple hiera example

2014-10-09 Thread jcbollinger


On Wednesday, October 8, 2014 8:44:56 AM UTC-5, Stack Kororā wrote:
>
> Greetings, 
>
>  I don't know why, but I am having a rough time trying to get hiera to 
> work. It seems to me that all the examples I see online are either absurdly 
> complex or so stupidly simple that they are absolutely useless. Either way 
> I have found the documentation for hiera completely lacking (it doesn't 
> help that there is a lot of bad information pertaining old puppet releases 
> that is no longer the correct way to do things...at least according to 
> other sources which may or may not be the correct way either...bleck...). 
> Of all the documentation/blogs/examples/ect I have been pouring over the 
> last 2 hours, not one has given me a useful hint at getting this working. 
>
>
>  *deep breath in an attempt to control my frustration so I can 
> communicate on a somewhat intelligent level* 
>
> Whew... 
>


Keep breathing.  Your frustration is coming through clearly -- and I don't 
blame you for it -- but Hiera really does work, and there's not much more 
to it than your research has already turned up.

 

>  OK. Lets start. 
>
>
>
[...]
 

> $ hiera hieratest::test clientcert=puppet.test.vm 
>
> yadda 
>
> # Hiera on the command line works. I must be making progress!!
>
>
> $ sudo puppet agent -t 
>
> Info: Retrieving pluginfacts 
>
> Info: Retrieving plugin 
>
> Info: Caching catalog for puppet.test.vm 
>
> Info: Applying configuration version '1412771807' 
>
> Notice: /Stage[main]/Testhiera/File[/tmp/blah]/ensure: created 
>
> Notice: Finished catalog run in 0.03 seconds 
>
>  
> What??? That is absolutely contrary to the documentation! It should have 
> created /tmp/yadda!
>


If the master had successfully looked up your datum then the result would 
have been as you expected.  The behavior you present is characteristic of 
(and well documented for) the case where the automatic lookup fails, 
leaving the master to fall back to the default value given in the class 
definition.  The problem is not in your Puppet manifests, and your CLI 
tests demonstrate that it is not in your data themselves, but those are not 
the only possibilities.

 

> I am looking at the official docs right now on using a hiera variable with 
> a default variable and I don't see how my example is any different in the 
> slightest! Blah should have only been used as a default if the host wasn't 
> found. Clearly either puppet can't find hiera and used default, or it 
> simply ignored the hiera data. 
>
>
>   Fine. We will take out the default blah and force it to use something 
> from hiera. 
>
>
> $ rm /tmp/blah 
>
> $ cat modules/testhiera/manifests/init.pp 
>
> class testhiera ( ) { 
>
> file { "/tmp/$test" : ensure => present} 
>
> } 
>
> $ sudo puppet agent -t 
>
> Info: Retrieving pluginfacts 
>
> Info: Retrieving plugin 
>
> Info: Caching catalog for puppet.test.vm 
>
> Info: Applying configuration version '1412773578' 
>
> Notice: Finished catalog run in 0.04 seconds 
>
>  
> What? No blah, no yadda, nothing! I don't even get an error!! 
>


How's hiera involved in that?  You now have $test as an uninitialized local 
variable (no longer a class parameter).  It expands to nothing when you 
interpolate it into your filename, so you're managing File["/tmp/"], which 
is equivalent to File["/tmp"].  That file (directory) already exists, and 
that's all you ask Puppet to ensure, so Puppet does nothing.

 

>  
> OK. OK. Fine. Maybe it doesn't like something in hiera. I will give hiera 
> a default. 
>

[...]

Unless you change the class back, you've already run off the rails here.  
You have no hiera lookup involved any more.


John

-- 
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/609b4371-30b3-41fd-82c0-02845d0550a9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Kai Timmer
2014-10-09 15:20 GMT+02:00 Ken Barber :
>
> No not necessarily, you need to enable resource purging with resources
> like nagios_host:
>
> resources { "nagios_host":
>   purge => true,
> }
>

Oh, I just did not now that. My manifest now looks like this:

  resources { ["nagios_host", "nagios_service"]:
purge => true,
  }

  #Collect the nagios_host resources
  Nagios_host <<||>> {
target  => "/etc/icinga/puppet.d/hosts.cfg",
require => File["/etc/icinga/puppet.d/hosts.cfg"],
notify => Service[icinga],
  }

But the entries don't get purged. Looks like I'm still missing something :/

Best regards,
Kai

-- 
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/CA%2B0qVEdKGbxEpnt19o-6nVHG4YLdm7ia8XojOPMv4sM_Sb%2BBYA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Need help with simple hiera example

2014-10-09 Thread jcbollinger


On Wednesday, October 8, 2014 8:09:28 PM UTC-5, Stack Kororā wrote:
 

> However, I did get it working and you reaffirmed something I had 
> discovered. So thank you very much for responding. I do appreciate it.
>
>
I'm glad you got it working.
 

> Since the documentation is near rubbish on hiera, I started digging around 
> in the code itself for the hiera projects that _do_ work for me. I noticed 
> that there were two methods that seemed to pop up frequently.
>
> 1) The method Corey mentioned:
> $bar = hiera('myfoo::bar', 'defaultvalue')
>
> However, the puppet docs basically say do this for 2.7 but not for 3+ [ 
> https://docs.puppetlabs.com/hiera/1/puppet.html ].
>


In Puppet 2, that was the only way you *could* do it.  After Puppet 3 was 
released, it was common for module authors to attempt to support both P2 
and P3, which tied them to that form.  Even with official support for the 
P2 series ending, there is probably still interest in compatibility from 
some quarters.

As for using *only* automatic parameter binding in P3, that's basically a 
code style argument, its position right in the documentation 
notwithstanding.  The advice is not bad as far as it goes, but do note that 
it also presents an apparently acceptable (albeit downplayed) alternative: 
explicitly document the hiera keys your class uses.  It seems like you've 
probably been around enough to see a code-style war or two, so I'll leave 
it there.

 

> Also note that there are two examples on that page which completely fail 
> (silently...at least in my example code).
> THIS DOESN'T WORK:
> 1.1) class myclass ( $parameter_one = hiera('myclass::parameter_one', 
> 'default text') 
>


That's hideous and wasteful (in current Puppet), but it ought to work.  
Hiera calls (and other function calls) do work in class parameter lists, 
unless there's been a regression I don't know about.  In that particular 
case, Puppet 3.x should perform two lookups of the same key.  The only 
reason to do it is for compatibility with Puppet 2.x, which does not have 
automated data binding (and therefore will perform only one lookup).

 

> 1.2) class myclass ($parameter_one = "default text") { ...content => 
> $parameter_one, ...}
>
> [...] will /always/ go to 'default text' for me. It has yet to pull back 
> the hiera data.
>
>

If that's true then something is dreadfully wrong in your environment.  
Class parameter defaults do not interfere with automated data binding.  
Puppet's automated test suite verifies this, so if you're seeing different 
behavior then there is some sort of local modification or environment issue 
that is causing breakage.  I hope you'll forgive me if I judge it more 
likely that your tests are misleading you.

 

> 2) $ cat modules/testhiera/manifests/init.pp 
> class testhiera ( $test = $hieratest::test ) {
>   file { "/tmp/$test" : ensure => present}
> }
>
>

How is that different from your 1.2, which you say doesn't work?

It seems like you may have a misconception: automated data binding applies 
specifically to class *parameters*, as an aspect of resolving their 
values.  It does not apply to class variables that are not parameters, and 
it is not automagically applied to parameters of classes that have not yet 
been evaluated.

Your code (2) is dangerous for one of two reasons:

   1. If the code is written as you intended, then it relies for a class 
   parameter default on a class variable of a different class, without doing 
   anything to ensure that that other class (hieratest) has been evaluated.  
   You can find extensive discussion of this issue and others related to using 
   other classes' variables for parameter defaults by googling "puppet params 
   class pattern".
   2. If you meant to write "class testhiera ( $test = $testhiera::test )", 
   then you are specifying the default value for class parameter 
   $teshiera::test to be itself.  In that case, that default value will be 
   used only in situations where it has not been intialized, so I think it's 
   functionally equivalent to "class testhiera ( $test = undef )".
   
Either way, your code will work fine as long as the hiera lookup for your 
class parameter succeeds (so that the default value is not consulted).  
It's what will happen when the lookup accidentally or intentionally *fails* 
that may come back to bite you in the assets.

 

> But, its working now! Hooray! 
>
>

Hooray!


John

-- 
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/927e2cc1-3dd2-4cb9-a28a-d86be89a6c05%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Could not set 'file on ensure: undefined method `&' for "760"

2014-10-09 Thread jcbollinger


On Wednesday, October 8, 2014 7:33:32 AM UTC-5, Torsten Amshove wrote:
>
> Ok, the other modules works because they don't create a new file.
>
> If the file on the puppet client exists, (even an empty one) everything 
> works fine - if you delete it, this error occures.
>
> ensure => present,
> and
> ensure => file,
> makes no difference
>
>

How about an example that causes the error for you?


John
 

-- 
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/d07a78a6-1ee3-463c-b59c-7569a3b0356e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: centos 7 boxes on vagrant cloud?

2014-10-09 Thread Chris Handy
awesome, thank you!

On Wednesday, October 8, 2014 5:15:25 PM UTC-4, Scott Schneider wrote:
>
> I was wondering when there will be official centos 7 boxes from puppet 
>> labs on https://vagrantcloud.com/puppetlabs?
>>
>> Also it would be nice to have a link on the puppet vagrant cloud homepage 
>> to what repo these boxes are generated from like the chef project does to 
>> https://github.com/opscode/bento.
>>
>
> Hi Chris,
>
> You've caught us in the middle of re-working our automated Vagrant imaging 
> pipeline.  I expect to have new builds published to Vagrant Cloud later 
> this week or early next week.
>
> We're also working on setting up a ticketing project for bug reporting and 
> publicizing our Packer repository, as suggested.  Stay tuned!
>

-- 
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/f7ca5c5f-abf6-4d4e-9dc8-b370c97a28c8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Jonathan Gazeley

On 09/10/14 15:11, Kai Timmer wrote:


2014-10-09 15:20 GMT+02:00 Ken Barber >:


No not necessarily, you need to enable resource purging with resources
like nagios_host:

resources { "nagios_host":
  purge => true,
}


Oh, I just did not now that. My manifest now looks like this:

  resources { ["nagios_host", "nagios_service"]:
purge => true,
  }

  #Collect the nagios_host resources
  Nagios_host <<||>> {
target  => "/etc/icinga/puppet.d/hosts.cfg",
require => File["/etc/icinga/puppet.d/hosts.cfg"],
notify => Service[icinga],
  }

But the entries don't get purged. Looks like I'm still missing 
something :/





I think you are running into this:

"You can purge Nagios resources using the resources type, but only in 
the default file locations. This is an architectural limitation."


https://docs.puppetlabs.com/references/latest/type.html#nagioscommand

i.e. if you set the target parameter, you lose the ability to purge.

--
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/5436A30F.8080006%40bristol.ac.uk.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Ken Barber
>> No not necessarily, you need to enable resource purging with resources
>> like nagios_host:
>>
>> resources { "nagios_host":
>>   purge => true,
>> }
>
>
> Oh, I just did not now that. My manifest now looks like this:
>
>   resources { ["nagios_host", "nagios_service"]:
> purge => true,
>   }
>
>   #Collect the nagios_host resources
>   Nagios_host <<||>> {
> target  => "/etc/icinga/puppet.d/hosts.cfg",
> require => File["/etc/icinga/puppet.d/hosts.cfg"],
> notify => Service[icinga],
>   }
>
> But the entries don't get purged. Looks like I'm still missing something :/
>
>
>
> I think you are running into this:
>
> "You can purge Nagios resources using the resources type, but only in the
> default file locations. This is an architectural limitation."
>
> https://docs.puppetlabs.com/references/latest/type.html#nagioscommand
>
> i.e. if you set the target parameter, you lose the ability to purge.

Well spotted Jonathan ... :-).

So Kai, you can provide fake this with soft-links to the icigna dir
from the expected nagios configuration directory. Or soft-link the
files themselves, up to you.

ken.

-- 
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/CAE4bNTme_hcT%3DWitVy3%3DLMqmP2rZu%3DB32MNidHovp8D%2B3s8kVA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Automatically remove deactivated host from icinga/nagios config

2014-10-09 Thread Kai Timmer
2014-10-09 17:06 GMT+02:00 Ken Barber :

> So Kai, you can provide fake this with soft-links to the icigna dir
> from the expected nagios configuration directory. Or soft-link the
> files themselves, up to you.
>

Thank you both a lot.

Now the (fake-)host gets removed but for some reason the icinga service
doesn't get reloaded. Do I need to add something else to the manifest? The
notification works fine when I add a host.

Thank you,
-- Kai Timmer / em...@kaitimmer.de

-- 
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/CA%2B0qVEfekcT7c6zfZvwrHPLR4YVkr1p2th5oCirv%3DYVW2y3%3D8g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: puppetboard unable to reach puppetb

2014-10-09 Thread Daniele Sluijters
Hi,

This doesn't look like a configuration error with regard to Puppetboard but 
one with regard to Apache. These lines:  configuration error:  couldn't 
perform authentication. AuthType not set!: /static/js/lists.js, referer: 
http://puppetboard.jokefire.com/ aren't generated by Puppetboard, it has no 
concept of authentication and AuthType is an Apache thing.

My bet is the "Require all granted" line. From what I can gleam 
from http://httpd.apache.org/docs/current/mod/mod_authz_core.html#require 
it would require a few more settings, AuthType, AuthName, 
AuthBasicProvider, AuthUserFile and AuthGroupFile.

Until you have authentication set up, replace that Require line with:

Order deny,allow
Allow from all

Let me know if this works for you,

-- 
Daniele Sluijters

-- 
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/dbf87344-3b72-486d-b67d-737642a12b76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: puppetboard unable to reach puppetb

2014-10-09 Thread Daniele Sluijters
Hi,

I missed the part where this actually still works but then throws the 
PuppetDB connection issues.

* How did you install Puppetboard, with this 
module: https://forge.puppetlabs.com/nibalizer/puppetboard?
* Are Puppetboard and PuppetDB running on the same machine?
* Can you show me your settings.py as documented 
here: https://github.com/nedap/puppetboard#settings

-- 
Daniele Sluijters

-- 
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/09357b9c-d898-4a55-b0b8-c82254d52c9a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: puppetboard unable to reach puppetb

2014-10-09 Thread Tim Dunphy
Hi Daniel,

 Thanks for getting back to me.

This doesn't look like a configuration error with regard to Puppetboard but
> one with regard to Apache. These lines:  configuration error:  couldn't
> perform authentication. AuthType not set!: /static/js/lists.js, referer:
> http://puppetboard.jokefire.com/ aren't generated by Puppetboard, it has
> no concept of authentication and AuthType is an Apache thing.
> My bet is the "Require all granted" line. From what I can gleam from
> http://httpd.apache.org/docs/current/mod/mod_authz_core.html#require it
> would require a few more settings, AuthType, AuthName, AuthBasicProvider,
> AuthUserFile and AuthGroupFile.
> Until you have authentication set up, replace that Require line with:
>
> Order deny,allow
> Allow from all



Ok so I changed my apache config to this:


ServerName puppetboard.jokefire.com
WSGIDaemonProcess puppetboard user=apache group=apache threads=5
WSGIScriptAlias / /var/www/puppetboard/wsgi.py
ErrorLog /var/log/httpd/puppetboard_error_log
CustomLog /var/log/httpd/puppetboard_access_log combined

Alias /static /usr/lib/python2.6/site-packages/puppetboard/static


WSGIProcessGroup puppetboard
WSGIApplicationGroup %{GLOBAL}
*Order deny,allow*
*Allow from all*




I also changed the directory and contents to be readable by apache:

[root@puppet:/etc/httpd/conf.d] #ls -ld
/usr/lib/python2.6/site-packages/puppetboard/static/
drwxr-xr-x. 4 apache apache 4096 Oct  8 12:47
/usr/lib/python2.6/site-packages/puppetboard/static/

I still get the error:

http://puppetboard.jokefire.com/


I missed the part where this actually still works but then throws the
> PuppetDB connection issues.
> * How did you install Puppetboard, with this module:
> https://forge.puppetlabs.com/nibalizer/puppetboard?
>

 I did it via python pip install. I tried using the puppet module
initially. But it threw a bunch of dependency errors on my system. So
rather than try to wrestle with those I decided to to try a pip install
which went ok.


> * Are Puppetboard and PuppetDB running on the same machine?
>

Yes! They are.


> * Can you show me your settings.py as documented here:
> https://github.com/nedap/puppetboard#settings



Sure! Here you go.

[root@puppet:~] #cat /var/www/puppetboard/settings.py
PUPPETDB_HOST = 'puppet.jokefire.com'
PUPPETDB_PORT = 8081
PUPPETDB_KEY  = '/etc/puppetdb/ssl/private.pem'
PUPPETDB_CERT = '/etc/puppetdb/ssl/public.pem'
PUPPETDB_SSL_VERIFY = True
PUPPETDB_KEY = None
PUPPETDB_CERT = None
PUPPETDB_TIMEOUT = 60
DEV_LISTEN_HOST = '127.0.0.1'
DEV_LISTEN_PORT = 5000
UNRESPONSIVE_HOURS = 2
ENABLE_QUERY = True
LOGLEVEL = 'debug'

I also tried the PUPPET_HOST with the IP of the machine, and with 0.0.0.0.
None of that seemed to make any difference!

Thanks again for getting back to me on this.

Tim





On Thu, Oct 9, 2014 at 12:10 PM, Daniele Sluijters <
daniele.sluijt...@gmail.com> wrote:

> Hi,
>
> I missed the part where this actually still works but then throws the
> PuppetDB connection issues.
>
> * How did you install Puppetboard, with this module:
> https://forge.puppetlabs.com/nibalizer/puppetboard?
> * Are Puppetboard and PuppetDB running on the same machine?
> * Can you show me your settings.py as documented here:
> https://github.com/nedap/puppetboard#settings
>
> --
> Daniele Sluijters
>
> --
> 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/09357b9c-d898-4a55-b0b8-c82254d52c9a%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

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


[Puppet Users] Re: Need help with simple hiera example

2014-10-09 Thread Tony Thayer


On Wednesday, October 8, 2014 6:44:56 AM UTC-7, Stack Kororā wrote:
>
> Greetings, 
>
>  I don't know why, but I am having a rough time trying to get hiera to 
> work. It seems to me that all the examples I see online are either absurdly 
> complex or so stupidly simple that they are absolutely useless. Either way 
> I have found the documentation for hiera completely lacking (it doesn't 
> help that there is a lot of bad information pertaining old puppet releases 
> that is no longer the correct way to do things...at least according to 
> other sources which may or may not be the correct way either...bleck...). 
> Of all the documentation/blogs/examples/ect I have been pouring over the 
> last 2 hours, not one has given me a useful hint at getting this working. 
>
>
>  *deep breath in an attempt to control my frustration so I can 
> communicate on a somewhat intelligent level* 
>
> Whew... 
>
>  OK. Lets start. 
>
>
>  $ puppet -V 
>
> 3.7.1 
>
> $ hiera -V 
>
> 1.3.4 
>
> $ hostname 
>
> puppet.test.vm 
>
> $ sudo puppet cert list --all 
>
> + "puppet.test.vm"  
>
>
>  This is as simple as I can make it. 
>
>
>  $ cd /etc/puppet 
>
> $ find . -type f 
>
> ./modules/testhiera/manifests/init.pp 
>
> ./manifests/site.pp 
>
> ./puppet.conf <- did not touch after test vm install 
>
> ./auth.conf <- did not touch after test vm install 
>
> $ cat manifests/site.pp 
>
> node 'puppet.test.vm' { 
>
> class { 'testhiera': } 
>
> } 
>
> $ cat modules/testhiera/manifests/init.pp 
>
> class testhiera ( $test="blah") { 
>
> file { "/tmp/$test" : ensure => present} 
>
> } 
>
> $ puppet agent -t 
>
> Info: Retrieving pluginfacts 
>
> Info: Retrieving plugin 
>
> Info: Caching catalog for puppet.test.vm 
>
> Info: Applying configuration version '1412771807' 
>
> Notice: /Stage[main]/Testhiera/File[/tmp/blah]/ensure: created 
>
> Notice: Finished catalog run in 0.04 seconds 
>
> $ rm /tmp/blah 
>
>   
> Hooray! That works. Can't get much simpler then that, right? OK, lets add 
> in hiera. Should be simple right? Ha!
>
>  
> $ sudo ln -s /etc/puppet/hiera.yaml /etc/hiera.yaml 
>
> $ find . -type f 
>
> ./hiera.yaml 
>
> ./hosts/puppet.test.vm.yaml 
>
> ./modules/testhiera/manifests/init.pp 
>
> ./manifests/site.pp 
>
> ./puppet.conf 
>
> ./auth.conf 
>
> # Only added these two files below; made no other changes 
>
> $ cat hiera.yaml 
>
> --- 
>
> :hierarchy: 
>
> - hosts/%{clientcert} 
>
> :backends: 
>
> - yaml 
>
> :yaml: 
>
> :datadir: '/etc/puppet/' 
>
> $ cat hosts/puppet.test.vm.yaml 
>
> --- 
>
> hieratest::test: yadda 
>
> $ hiera hieratest::test clientcert=puppet.test.vm 
>
> yadda 
>
> # Hiera on the command line works. I must be making progress!!
>
>
> $ sudo puppet agent -t 
>
> Info: Retrieving pluginfacts 
>
> Info: Retrieving plugin 
>
> Info: Caching catalog for puppet.test.vm 
>
> Info: Applying configuration version '1412771807' 
>
> Notice: /Stage[main]/Testhiera/File[/tmp/blah]/ensure: created 
>
> Notice: Finished catalog run in 0.03 seconds 
>
>  
> What??? That is absolutely contrary to the documentation! It should have 
> created /tmp/yadda! I am looking at the official docs right now on using a 
> hiera variable with a default variable and I don't see how my example is 
> any different in the slightest! Blah should have only been used as a 
> default if the host wasn't found. Clearly either puppet can't find hiera 
> and used default, or it simply ignored the hiera data. 
>
>
>   Fine. We will take out the default blah and force it to use something 
> from hiera. 
>
>
> $ rm /tmp/blah 
>
> $ cat modules/testhiera/manifests/init.pp 
>
> class testhiera ( ) { 
>
> file { "/tmp/$test" : ensure => present} 
>
> } 
>
> $ sudo puppet agent -t 
>
> Info: Retrieving pluginfacts 
>
> Info: Retrieving plugin 
>
> Info: Caching catalog for puppet.test.vm 
>
> Info: Applying configuration version '1412773578' 
>
> Notice: Finished catalog run in 0.04 seconds 
>
>  
> What? No blah, no yadda, nothing! I don't even get an error!! 
>
>  
> OK. OK. Fine. Maybe it doesn't like something in hiera. I will give hiera 
> a default. 
>
>
> $ find . -type f 
>
> ./hiera.yaml 
>
> ./modules/testhiera/manifests/init.pp 
>
> ./puppet.conf 
>
> ./hosts/common.yaml 
>
> ./hosts/puppet.test.vm.yaml 
>
> ./auth.conf 
>
> ./manifests/site.pp 
>
> $ cat hiera.yaml 
>
> --- 
>
> :hierarchy: 
>
> - hosts/%{clientcert} 
>
> - hosts/common 
>
> :backends: 
>
> - yaml 
>
> :yaml: 
>
> :datadir: '/etc/puppet/' 
>
> $ cat hosts/common.yaml 
>
> --- 
>
> hieratest::test: blarg 
>
> $ hiera hieratest::test clientcert=puppet.test.vm 
>
> yadda 
>
> $ hiera hieratest::test clientcert=some.thing.else 
>
> blarg 
>
>  
> Yeah...alright...hiera on the command line is giving me exactly what I 
> want. I have feeling good about this one... 
>
>
> $ sudo puppet agent -t 
>
> Info: Retrieving pluginfacts 
>
> Info: Retrieving plugin 
>
> Info: Caching catalog for puppet.test.vm 
>
> Info: Applying configuration version '1412773578' 
>
> Notice: F

Re: [Puppet Users] Re: puppetboard unable to reach puppetb

2014-10-09 Thread Daniele Sluijters
Hey,

I think I know what's going on here. You've, dutifully, told Puppetboard 
that it needs to validate the server certificate that PuppetDB is 
presenting you with (PUPPETDB_SSL_VERIFY) when you setup a connection. 
However, I'm betting your OS trust-store does not include a copy of the 
Puppet Master CA, the one that handed out PuppetDB's server certificate.

What you need to do is change PUPPETDB_SSL_VERIFY from True to 
/var/lib/puppet/ssl/ca/ca.pem (I think that's the path). What also is 
slightly weird is that you have defined PUPPETDB_KEY and PUPPETDB_CERT 
twice, the latter having it set to None which I'm guessing is what 
Puppetboard ends up picking.

However, since your PuppetDB and Puppetboard are hosted on the same machine 
you can forgo the whole SSL debacle and use a local, plain connection 
instead. Since this traffic will never leave the host people would need to 
be logged in to your master to intercept it. Your settings.py then looks 
like this:

PUPPETDB_HOST = 'localhost'
PUPPETDB_PORT = 8080
PUPPETDB_TIMEOUT = 60

Once that works for you don't forget to change the LOGLEVEL back to 'info'.

-- 
Daniele Sluijters

On Thursday, 9 October 2014 09:24:08 UTC-7, bluethundr wrote:
>
> Hi Daniel,
>
>  Thanks for getting back to me. 
>
> This doesn't look like a configuration error with regard to Puppetboard 
>> but one with regard to Apache. These lines:  configuration error: 
>>  couldn't perform authentication. AuthType not set!: /static/js/lists.js, 
>> referer: http://puppetboard.jokefire.com/ aren't generated by 
>> Puppetboard, it has no concept of authentication and AuthType is an Apache 
>> thing.
>> My bet is the "Require all granted" line. From what I can gleam from 
>> http://httpd.apache.org/docs/current/mod/mod_authz_core.html#require it 
>> would require a few more settings, AuthType, AuthName, AuthBasicProvider, 
>> AuthUserFile and AuthGroupFile.
>> Until you have authentication set up, replace that Require line with:
>> 
>> Order deny,allow
>> Allow from all
>
>
>
> Ok so I changed my apache config to this:
>
> 
> ServerName puppetboard.jokefire.com
> WSGIDaemonProcess puppetboard user=apache group=apache threads=5
> WSGIScriptAlias / /var/www/puppetboard/wsgi.py
> ErrorLog /var/log/httpd/puppetboard_error_log
> CustomLog /var/log/httpd/puppetboard_access_log combined
>
> Alias /static /usr/lib/python2.6/site-packages/puppetboard/static
>
> 
> WSGIProcessGroup puppetboard
> WSGIApplicationGroup %{GLOBAL}
> *Order deny,allow*
> *Allow from all*
> 
> 
>
>
> I also changed the directory and contents to be readable by apache:
>
> [root@puppet:/etc/httpd/conf.d] #ls -ld 
> /usr/lib/python2.6/site-packages/puppetboard/static/
> drwxr-xr-x. 4 apache apache 4096 Oct  8 12:47 
> /usr/lib/python2.6/site-packages/puppetboard/static/
>
> I still get the error:
>
> http://puppetboard.jokefire.com/
>
>
> I missed the part where this actually still works but then throws the 
>> PuppetDB connection issues.
>> * How did you install Puppetboard, with this module: 
>> https://forge.puppetlabs.com/nibalizer/puppetboard?
>>
>
>  I did it via python pip install. I tried using the puppet module 
> initially. But it threw a bunch of dependency errors on my system. So 
> rather than try to wrestle with those I decided to to try a pip install 
> which went ok.
>  
>
>> * Are Puppetboard and PuppetDB running on the same machine?
>>
>
> Yes! They are.
>  
>
>> * Can you show me your settings.py as documented here: 
>> https://github.com/nedap/puppetboard#settings
>
>
>
> Sure! Here you go.
>
> [root@puppet:~] #cat /var/www/puppetboard/settings.py
> PUPPETDB_HOST = 'puppet.jokefire.com'
> PUPPETDB_PORT = 8081
> PUPPETDB_KEY  = '/etc/puppetdb/ssl/private.pem'
> PUPPETDB_CERT = '/etc/puppetdb/ssl/public.pem'
> PUPPETDB_SSL_VERIFY = True
> PUPPETDB_KEY = None
> PUPPETDB_CERT = None
> PUPPETDB_TIMEOUT = 60
> DEV_LISTEN_HOST = '127.0.0.1'
> DEV_LISTEN_PORT = 5000
> UNRESPONSIVE_HOURS = 2
> ENABLE_QUERY = True
> LOGLEVEL = 'debug'
>
> I also tried the PUPPET_HOST with the IP of the machine, and with 0.0.0.0. 
> None of that seemed to make any difference!
>
> Thanks again for getting back to me on this.
>
> Tim
>
>
>
>  
>
> On Thu, Oct 9, 2014 at 12:10 PM, Daniele Sluijters  > wrote:
>
>> Hi,
>>
>> I missed the part where this actually still works but then throws the 
>> PuppetDB connection issues.
>>
>> * How did you install Puppetboard, with this module: 
>> https://forge.puppetlabs.com/nibalizer/puppetboard?
>> * Are Puppetboard and PuppetDB running on the same machine?
>> * Can you show me your settings.py as documented here: 
>> https://github.com/nedap/puppetboard#settings
>>
>> -- 
>> Daniele Sluijters
>>
>> -- 
>> 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...

[Puppet Users] Puppet development IDE (Geppetto) integrated within Eclipse using puppet & hiera - puppet module

2014-10-09 Thread soumen trivedi
I have created a puppet module that will setup an eclipse platform and 
integrate eclipes features using Eclipes p2 director. I have a working 
eclipse platform with geppetto, dltk, egit & grep console features 
integrated within my development environment. 

As eclipse is one of many defacto-standards for IDE based development, I 
believe it would be easy for rollout and acceptance within the dev 
community.

https://github.com/soumentrivedi/puppet-eclipse_platform

It would be helpful if you can share some feedback on this module (rspec & 
beaker test are in progress and will be updated in due course).

This module is based on 
the https://forge.puppetlabs.com/runthebusiness/eclipse and re-uses some of 
its features and extends the plugin deployment through hiera rather than 
static parameter set.

-- 
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/1e2b1221-ad53-4c51-8f58-206781e6c9fa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Puppet development IDE (Geppetto) integrated within Eclipse using puppet & hiera - puppet module

2014-10-09 Thread Juan Andres Ramirez
THis module is for Eclipse??, install Eclipse and add this module?.

On Thursday, October 9, 2014 3:51:44 PM UTC-3, soumen trivedi wrote:
>
> I have created a puppet module that will setup an eclipse platform and 
> integrate eclipes features using Eclipes p2 director. I have a working 
> eclipse platform with geppetto, dltk, egit & grep console features 
> integrated within my development environment. 
>
> As eclipse is one of many defacto-standards for IDE based development, I 
> believe it would be easy for rollout and acceptance within the dev 
> community.
>
> https://github.com/soumentrivedi/puppet-eclipse_platform
>
> It would be helpful if you can share some feedback on this module (rspec & 
> beaker test are in progress and will be updated in due course).
>
> This module is based on the 
> https://forge.puppetlabs.com/runthebusiness/eclipse and re-uses some of 
> its features and extends the plugin deployment through hiera rather than 
> static parameter set.
>

-- 
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/27e8deb3-a2a7-4f7b-b325-3bb731afc2b5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Passing Parameters to Powershell

2014-10-09 Thread Paul Ponzeka
I am using Puppet installed with the powershell module.  I am struggling 
with how to pass a puppet variable through to powershell.  For instance I 
have the following in my module *init.pp* file:

class windows_dns(

$forwarders = '1.1.1.1'

) {
   anchor { 'windows_dns::begin': } ->
   class{'windows_dns::install': } ->
   class{'windows_dns::config': } ->
   class{'windows_dns::service': } ->
   anchor { 'windows_dns::end': }

}


Then in my *config.pp* file I have:

class windows_dns::config {

case $kernelmajversion {
6.3: {
$forwarder_execute = 
'windows_dns/setdnsforwarders.ps1'
$forwarder_check = 'windows_dns/checkdnsforwarders.ps1'
$dnsforwarders = $windows_dns::forwarders

}
6.1: {
$forwarder_execute = 
'windows_dns/setdnsforwarders_legacy.ps1'
$forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1'

}
}

exec { 'forwarderscreate':

command => template ($forwarder_execute),
unless => template ($forwarder_check),
provider => powershell,
logoutput => true,

}

I have stored as a template in the manifest a powershell script file as:

$dnsforwarders | out-file C:\test.log

I obviously want to use a more complex output.  I tried adding a parameter 
to the top of my powershell script but dont understand how to pass that as 
an option to puppet.  

The variable passes through fine.  I tested by changing the command to 
*command=> 
template ($dnsforwarders)* and i of course got an error from puppet about 
it not being able to find the template named *1.1.1.1* in the manifest.  I 
just dont know how to pass this through to the shell. 

-- 
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/6a394e94-7ec7-4cd5-b6b6-a89321f354b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: puppetboard unable to reach puppetb

2014-10-09 Thread Tim Dunphy
Hey Daniele,

 Thanks for your feedback! And especially your suggestion to forego SSL
since I'm running puppetb and puppetboard on the same host.

Anyway, here's my jetty.ini file from puppetdb:

[root@puppet:/etc/puppetdb/conf.d] #cat jetty.ini | grep -v '#'
[jetty]

port = 8082



ssl-host = 216.120.250.140

ssl-port = 8081

ssl-key = /etc/puppetdb/ssl/private.pem

ssl-cert = /etc/puppetdb/ssl/public.pem

ssl-ca-cert = /etc/puppetdb/ssl/ca.pem

And I set my settings.py to what you suggested:

[root@puppet:/etc/puppetdb/conf.d] #cat /var/www/puppetboard/settings.py
PUPPETDB_HOST = 'localhost'
PUPPETDB_PORT = 8082
PUPPETDB_TIMEOUT = 60

And look at that!!!

http://puppetboard.jokefire.com/

The puppetboard started filling in with data. However, all my nodes are
showing up as 'unreported'.

Which is odd because I am also running foreman on the same machine. And if
I look there, foreman is claiming that all my nodes have reported in.

Could I now be having an issue with the puppetdb itself?

if so I don't see anything telling in the puppetdb logs:

[root@puppet:/etc/puppetdb/conf.d] #tail -f /var/log/puppetdb/puppetdb.log
2014-10-09 15:27:29,822 INFO  [c.p.p.command]
[833e757a-929b-4e7d-9f4b-82728e0e1659] [replace catalog] ldap02.jokefire.com
2014-10-09 15:27:31,362 INFO  [c.p.p.command]
[4b4c50ab-8437-4f8f-917a-138e6c97d464] [replace catalog] mail.jokefire.com
2014-10-09 15:27:46,117 INFO  [c.p.p.command]
[20bf87fc-2a1b-4a30-8877-0273439b8620] [replace facts] monitor.jokefire.com
2014-10-09 15:27:48,468 INFO  [c.p.p.command]
[6714cdd3-64a1-49e7-b69c-575680e7fe9d] [replace catalog]
monitor.jokefire.com
2014-10-09 15:27:53,481 INFO  [c.p.p.command]
[0d3b94a2-2013-479c-bf7a-d3dc6d04bdae] [replace facts] ldap02.jokefire.com
2014-10-09 15:27:55,420 INFO  [c.p.p.command]
[a5d7e16c-ef1f-469b-9a57-a1bb5fa7f884] [replace catalog] ldap02.jokefire.com
2014-10-09 15:28:05,156 INFO  [c.p.p.command]
[4c677d3a-7b74-48ca-9c02-51884b8aa7cb] [replace facts] monitor.jokefire.com
2014-10-09 15:28:07,418 INFO  [c.p.p.command]
[80aa84a3-bbfe-4900-85ae-7727b5a6fb4f] [replace catalog]
monitor.jokefire.com
2014-10-09 15:28:15,070 INFO  [c.p.p.command]
[58fc68ac-3535-4dbf-bad1-574de9ed7247] [replace facts] ldap02.jokefire.com
2014-10-09 15:28:16,462 INFO  [c.p.p.command]
[20695d20-19da-42b3-a5cb-ed933dda3cb3] [replace catalog] ldap02.jokefire.com


Thanks for your help! Looks as if we are making some progress here!
Tim




On Thu, Oct 9, 2014 at 2:36 PM, Daniele Sluijters <
daniele.sluijt...@gmail.com> wrote:

> Hey,
>
> I think I know what's going on here. You've, dutifully, told Puppetboard
> that it needs to validate the server certificate that PuppetDB is
> presenting you with (PUPPETDB_SSL_VERIFY) when you setup a connection.
> However, I'm betting your OS trust-store does not include a copy of the
> Puppet Master CA, the one that handed out PuppetDB's server certificate.
>
> What you need to do is change PUPPETDB_SSL_VERIFY from True to
> /var/lib/puppet/ssl/ca/ca.pem (I think that's the path). What also is
> slightly weird is that you have defined PUPPETDB_KEY and PUPPETDB_CERT
> twice, the latter having it set to None which I'm guessing is what
> Puppetboard ends up picking.
>
> However, since your PuppetDB and Puppetboard are hosted on the same
> machine you can forgo the whole SSL debacle and use a local, plain
> connection instead. Since this traffic will never leave the host people
> would need to be logged in to your master to intercept it. Your settings.py
> then looks like this:
>
> PUPPETDB_HOST = 'localhost'
> PUPPETDB_PORT = 8080
> PUPPETDB_TIMEOUT = 60
>
> Once that works for you don't forget to change the LOGLEVEL back to 'info'.
>
> --
> Daniele Sluijters
>
> On Thursday, 9 October 2014 09:24:08 UTC-7, bluethundr wrote:
>
>> Hi Daniel,
>>
>>  Thanks for getting back to me.
>>
>> This doesn't look like a configuration error with regard to Puppetboard
>>> but one with regard to Apache. These lines:  configuration error:
>>>  couldn't perform authentication. AuthType not set!: /static/js/lists.js,
>>> referer: http://puppetboard.jokefire.com/ aren't generated by
>>> Puppetboard, it has no concept of authentication and AuthType is an Apache
>>> thing.
>>> My bet is the "Require all granted" line. From what I can gleam from
>>> http://httpd.apache.org/docs/current/mod/mod_authz_core.html#require it
>>> would require a few more settings, AuthType, AuthName, AuthBasicProvider,
>>> AuthUserFile and AuthGroupFile.
>>> Until you have authentication set up, replace that Require line with:
>>>
>>> Order deny,allow
>>> Allow from all
>>
>>
>>
>> Ok so I changed my apache config to this:
>>
>> 
>> ServerName puppetboard.jokefire.com
>> WSGIDaemonProcess puppetboard user=apache group=apache threads=5
>> WSGIScriptAlias / /var/www/puppetboard/wsgi.py
>> ErrorLog /var/log/httpd/puppetboard_error_log
>> CustomLog /var/log/httpd/puppetboard_access_log combined
>>
>> Alias /static /usr/lib/py

[Puppet Users] Re: Passing Parameters to Powershell

2014-10-09 Thread Juan Andres Ramirez
if you want execute a powershell file:

 command => "powershell.exe -ExecutionPolicy ByPass -File file.ps1 
${param1}"

On Thursday, October 9, 2014 4:22:14 PM UTC-3, Paul Ponzeka wrote:
>
> I am using Puppet installed with the powershell module.  I am struggling 
> with how to pass a puppet variable through to powershell.  For instance I 
> have the following in my module *init.pp* file:
>
> class windows_dns(
>
> $forwarders = '1.1.1.1'
>
> ) {
>anchor { 'windows_dns::begin': } ->
>class{'windows_dns::install': } ->
>class{'windows_dns::config': } ->
>class{'windows_dns::service': } ->
>anchor { 'windows_dns::end': }
>
> }
>
>
> Then in my *config.pp* file I have:
>
> class windows_dns::config {
>
> case $kernelmajversion {
> 6.3: {
> $forwarder_execute = 
> 'windows_dns/setdnsforwarders.ps1'
> $forwarder_check = 'windows_dns/checkdnsforwarders.ps1'
> $dnsforwarders = $windows_dns::forwarders
>
> }
> 6.1: {
> $forwarder_execute = 
> 'windows_dns/setdnsforwarders_legacy.ps1'
> $forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1'
>
> }
> }
>
> exec { 'forwarderscreate':
>
> command => template ($forwarder_execute),
> unless => template ($forwarder_check),
> provider => powershell,
> logoutput => true,
>
> }
>
> I have stored as a template in the manifest a powershell script file as:
>
> $dnsforwarders | out-file C:\test.log
>
> I obviously want to use a more complex output.  I tried adding a parameter 
> to the top of my powershell script but dont understand how to pass that as 
> an option to puppet.  
>
> The variable passes through fine.  I tested by changing the command to 
> *command=> 
> template ($dnsforwarders)* and i of course got an error from puppet about 
> it not being able to find the template named *1.1.1.1* in the manifest. 
>  I just dont know how to pass this through to the shell. 
>

-- 
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/d9fc7278-294d-45ef-9cea-ee9efc43748f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: puppetboard unable to reach puppetb

2014-10-09 Thread Spencer Krum
Are you pushing reports into puppetdb or only into foreman?

On Thu, Oct 9, 2014 at 12:29 PM, Tim Dunphy  wrote:

> Hey Daniele,
>
>  Thanks for your feedback! And especially your suggestion to forego SSL
> since I'm running puppetb and puppetboard on the same host.
>
> Anyway, here's my jetty.ini file from puppetdb:
>
> [root@puppet:/etc/puppetdb/conf.d] #cat jetty.ini | grep -v '#'
> [jetty]
>
> port = 8082
>
>
>
> ssl-host = 216.120.250.140
>
> ssl-port = 8081
>
> ssl-key = /etc/puppetdb/ssl/private.pem
>
> ssl-cert = /etc/puppetdb/ssl/public.pem
>
> ssl-ca-cert = /etc/puppetdb/ssl/ca.pem
>
> And I set my settings.py to what you suggested:
>
> [root@puppet:/etc/puppetdb/conf.d] #cat /var/www/puppetboard/settings.py
> PUPPETDB_HOST = 'localhost'
> PUPPETDB_PORT = 8082
> PUPPETDB_TIMEOUT = 60
>
> And look at that!!!
>
> http://puppetboard.jokefire.com/
>
> The puppetboard started filling in with data. However, all my nodes are
> showing up as 'unreported'.
>
> Which is odd because I am also running foreman on the same machine. And if
> I look there, foreman is claiming that all my nodes have reported in.
>
> Could I now be having an issue with the puppetdb itself?
>
> if so I don't see anything telling in the puppetdb logs:
>
> [root@puppet:/etc/puppetdb/conf.d] #tail -f /var/log/puppetdb/puppetdb.log
> 2014-10-09 15:27:29,822 INFO  [c.p.p.command]
> [833e757a-929b-4e7d-9f4b-82728e0e1659] [replace catalog]
> ldap02.jokefire.com
> 2014-10-09 15:27:31,362 INFO  [c.p.p.command]
> [4b4c50ab-8437-4f8f-917a-138e6c97d464] [replace catalog] mail.jokefire.com
> 2014-10-09 15:27:46,117 INFO  [c.p.p.command]
> [20bf87fc-2a1b-4a30-8877-0273439b8620] [replace facts]
> monitor.jokefire.com
> 2014-10-09 15:27:48,468 INFO  [c.p.p.command]
> [6714cdd3-64a1-49e7-b69c-575680e7fe9d] [replace catalog]
> monitor.jokefire.com
> 2014-10-09 15:27:53,481 INFO  [c.p.p.command]
> [0d3b94a2-2013-479c-bf7a-d3dc6d04bdae] [replace facts] ldap02.jokefire.com
> 2014-10-09 15:27:55,420 INFO  [c.p.p.command]
> [a5d7e16c-ef1f-469b-9a57-a1bb5fa7f884] [replace catalog]
> ldap02.jokefire.com
> 2014-10-09 15:28:05,156 INFO  [c.p.p.command]
> [4c677d3a-7b74-48ca-9c02-51884b8aa7cb] [replace facts]
> monitor.jokefire.com
> 2014-10-09 15:28:07,418 INFO  [c.p.p.command]
> [80aa84a3-bbfe-4900-85ae-7727b5a6fb4f] [replace catalog]
> monitor.jokefire.com
> 2014-10-09 15:28:15,070 INFO  [c.p.p.command]
> [58fc68ac-3535-4dbf-bad1-574de9ed7247] [replace facts] ldap02.jokefire.com
> 2014-10-09 15:28:16,462 INFO  [c.p.p.command]
> [20695d20-19da-42b3-a5cb-ed933dda3cb3] [replace catalog]
> ldap02.jokefire.com
>
>
> Thanks for your help! Looks as if we are making some progress here!
> Tim
>
>
>
>
> On Thu, Oct 9, 2014 at 2:36 PM, Daniele Sluijters <
> daniele.sluijt...@gmail.com> wrote:
>
>> Hey,
>>
>> I think I know what's going on here. You've, dutifully, told Puppetboard
>> that it needs to validate the server certificate that PuppetDB is
>> presenting you with (PUPPETDB_SSL_VERIFY) when you setup a connection.
>> However, I'm betting your OS trust-store does not include a copy of the
>> Puppet Master CA, the one that handed out PuppetDB's server certificate.
>>
>> What you need to do is change PUPPETDB_SSL_VERIFY from True to
>> /var/lib/puppet/ssl/ca/ca.pem (I think that's the path). What also is
>> slightly weird is that you have defined PUPPETDB_KEY and PUPPETDB_CERT
>> twice, the latter having it set to None which I'm guessing is what
>> Puppetboard ends up picking.
>>
>> However, since your PuppetDB and Puppetboard are hosted on the same
>> machine you can forgo the whole SSL debacle and use a local, plain
>> connection instead. Since this traffic will never leave the host people
>> would need to be logged in to your master to intercept it. Your settings.py
>> then looks like this:
>>
>> PUPPETDB_HOST = 'localhost'
>> PUPPETDB_PORT = 8080
>> PUPPETDB_TIMEOUT = 60
>>
>> Once that works for you don't forget to change the LOGLEVEL back to
>> 'info'.
>>
>> --
>> Daniele Sluijters
>>
>> On Thursday, 9 October 2014 09:24:08 UTC-7, bluethundr wrote:
>>
>>> Hi Daniel,
>>>
>>>  Thanks for getting back to me.
>>>
>>> This doesn't look like a configuration error with regard to Puppetboard
 but one with regard to Apache. These lines:  configuration error:
  couldn't perform authentication. AuthType not set!: /static/js/lists.js,
 referer: http://puppetboard.jokefire.com/ aren't generated by
 Puppetboard, it has no concept of authentication and AuthType is an Apache
 thing.
 My bet is the "Require all granted" line. From what I can gleam from
 http://httpd.apache.org/docs/current/mod/mod_authz_core.html#require it
 would require a few more settings, AuthType, AuthName, AuthBasicProvider,
 AuthUserFile and AuthGroupFile.
 Until you have authentication set up, replace that Require line with:

 Order deny,allow
 Allow from all
>>>
>>>
>>>
>>> Ok so I changed my apache config to this:
>>>
>>> 
>>> 

[Puppet Users] Re: Passing Parameters to Powershell

2014-10-09 Thread Paul Ponzeka
Thanks Juan.  Couple of questions on your reply.


   1. In my case would it be the following: command => "powershell.exe 
   -ExecutionPolicy ByPass -File file.ps1 ${dnsforwarders}"  # or does this 
   need to be adjusted?
   2. How do i do the same with the fact that I am using templates, and 
   thus they are stored on Puppet and passed to the server.  I am not storing 
   the powershell files on the agent server. Is there a way to do something 
   like the following:

command => template ($forwarder_execute) ${Param1},  #

On Thursday, October 9, 2014 3:35:59 PM UTC-4, Juan Andres Ramirez wrote:
>
> if you want execute a powershell file:
>
>  command => "powershell.exe -ExecutionPolicy ByPass -File file.ps1 
> ${param1}"
>
> On Thursday, October 9, 2014 4:22:14 PM UTC-3, Paul Ponzeka wrote:
>>
>> I am using Puppet installed with the powershell module.  I am struggling 
>> with how to pass a puppet variable through to powershell.  For instance I 
>> have the following in my module *init.pp* file:
>>
>> class windows_dns(
>>
>> $forwarders = '1.1.1.1'
>>
>> ) {
>>anchor { 'windows_dns::begin': } ->
>>class{'windows_dns::install': } ->
>>class{'windows_dns::config': } ->
>>class{'windows_dns::service': } ->
>>anchor { 'windows_dns::end': }
>>
>> }
>>
>>
>> Then in my *config.pp* file I have:
>>
>> class windows_dns::config {
>>
>> case $kernelmajversion {
>> 6.3: {
>> $forwarder_execute = 
>> 'windows_dns/setdnsforwarders.ps1'
>> $forwarder_check = 'windows_dns/checkdnsforwarders.ps1'
>> $dnsforwarders = $windows_dns::forwarders
>>
>> }
>> 6.1: {
>> $forwarder_execute = 
>> 'windows_dns/setdnsforwarders_legacy.ps1'
>> $forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1'
>>
>> }
>> }
>>
>> exec { 'forwarderscreate':
>>
>> command => template ($forwarder_execute),
>> unless => template ($forwarder_check),
>> provider => powershell,
>> logoutput => true,
>>
>> }
>>
>> I have stored as a template in the manifest a powershell script file as:
>>
>> $dnsforwarders | out-file C:\test.log
>>
>> I obviously want to use a more complex output.  I tried adding a 
>> parameter to the top of my powershell script but dont understand how to 
>> pass that as an option to puppet.  
>>
>> The variable passes through fine.  I tested by changing the command to 
>> *command=> 
>> template ($dnsforwarders)* and i of course got an error from puppet 
>> about it not being able to find the template named *1.1.1.1* in the 
>> manifest.  I just dont know how to pass this through to the shell. 
>>
>

-- 
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/5eab4876-2e68-4d3a-a6cd-a931b0daa5a4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: puppetboard unable to reach puppetb

2014-10-09 Thread Tim Dunphy
Hey Spencer,



> Are you pushing reports into puppetdb or only into foreman?



Ok so I missed that. Sorry dude. And yeah as you point out I originally had
reports only going to foreman. But I changed the puppet.conf to this:

[root@puppet:/etc/puppet] #egrep -i "reports|storeconfigs" puppet.conf
reports= foreman puppetdb
storeconfigs = true
storeconfigs_backend = puppetdb


I wasn't sure if this was supposed to be comma dlimeted or space. I tried
using a space between the two.

And so far no change.

http://puppetboard.jokefire.com/


thanks

On Thu, Oct 9, 2014 at 3:38 PM, Spencer Krum  wrote:

> Are you pushing reports into puppetdb or only into foreman?
>
> On Thu, Oct 9, 2014 at 12:29 PM, Tim Dunphy  wrote:
>
>> Hey Daniele,
>>
>>  Thanks for your feedback! And especially your suggestion to forego SSL
>> since I'm running puppetb and puppetboard on the same host.
>>
>> Anyway, here's my jetty.ini file from puppetdb:
>>
>> [root@puppet:/etc/puppetdb/conf.d] #cat jetty.ini | grep -v '#'
>> [jetty]
>>
>> port = 8082
>>
>>
>>
>> ssl-host = 216.120.250.140
>>
>> ssl-port = 8081
>>
>> ssl-key = /etc/puppetdb/ssl/private.pem
>>
>> ssl-cert = /etc/puppetdb/ssl/public.pem
>>
>> ssl-ca-cert = /etc/puppetdb/ssl/ca.pem
>>
>> And I set my settings.py to what you suggested:
>>
>> [root@puppet:/etc/puppetdb/conf.d] #cat /var/www/puppetboard/settings.py
>> PUPPETDB_HOST = 'localhost'
>> PUPPETDB_PORT = 8082
>> PUPPETDB_TIMEOUT = 60
>>
>> And look at that!!!
>>
>> http://puppetboard.jokefire.com/
>>
>> The puppetboard started filling in with data. However, all my nodes are
>> showing up as 'unreported'.
>>
>> Which is odd because I am also running foreman on the same machine. And
>> if I look there, foreman is claiming that all my nodes have reported in.
>>
>> Could I now be having an issue with the puppetdb itself?
>>
>> if so I don't see anything telling in the puppetdb logs:
>>
>> [root@puppet:/etc/puppetdb/conf.d] #tail -f
>> /var/log/puppetdb/puppetdb.log
>> 2014-10-09 15:27:29,822 INFO  [c.p.p.command]
>> [833e757a-929b-4e7d-9f4b-82728e0e1659] [replace catalog]
>> ldap02.jokefire.com
>> 2014-10-09 15:27:31,362 INFO  [c.p.p.command]
>> [4b4c50ab-8437-4f8f-917a-138e6c97d464] [replace catalog]
>> mail.jokefire.com
>> 2014-10-09 15:27:46,117 INFO  [c.p.p.command]
>> [20bf87fc-2a1b-4a30-8877-0273439b8620] [replace facts]
>> monitor.jokefire.com
>> 2014-10-09 15:27:48,468 INFO  [c.p.p.command]
>> [6714cdd3-64a1-49e7-b69c-575680e7fe9d] [replace catalog]
>> monitor.jokefire.com
>> 2014-10-09 15:27:53,481 INFO  [c.p.p.command]
>> [0d3b94a2-2013-479c-bf7a-d3dc6d04bdae] [replace facts]
>> ldap02.jokefire.com
>> 2014-10-09 15:27:55,420 INFO  [c.p.p.command]
>> [a5d7e16c-ef1f-469b-9a57-a1bb5fa7f884] [replace catalog]
>> ldap02.jokefire.com
>> 2014-10-09 15:28:05,156 INFO  [c.p.p.command]
>> [4c677d3a-7b74-48ca-9c02-51884b8aa7cb] [replace facts]
>> monitor.jokefire.com
>> 2014-10-09 15:28:07,418 INFO  [c.p.p.command]
>> [80aa84a3-bbfe-4900-85ae-7727b5a6fb4f] [replace catalog]
>> monitor.jokefire.com
>> 2014-10-09 15:28:15,070 INFO  [c.p.p.command]
>> [58fc68ac-3535-4dbf-bad1-574de9ed7247] [replace facts]
>> ldap02.jokefire.com
>> 2014-10-09 15:28:16,462 INFO  [c.p.p.command]
>> [20695d20-19da-42b3-a5cb-ed933dda3cb3] [replace catalog]
>> ldap02.jokefire.com
>>
>>
>> Thanks for your help! Looks as if we are making some progress here!
>> Tim
>>
>>
>>
>>
>> On Thu, Oct 9, 2014 at 2:36 PM, Daniele Sluijters <
>> daniele.sluijt...@gmail.com> wrote:
>>
>>> Hey,
>>>
>>> I think I know what's going on here. You've, dutifully, told Puppetboard
>>> that it needs to validate the server certificate that PuppetDB is
>>> presenting you with (PUPPETDB_SSL_VERIFY) when you setup a connection.
>>> However, I'm betting your OS trust-store does not include a copy of the
>>> Puppet Master CA, the one that handed out PuppetDB's server certificate.
>>>
>>> What you need to do is change PUPPETDB_SSL_VERIFY from True to
>>> /var/lib/puppet/ssl/ca/ca.pem (I think that's the path). What also is
>>> slightly weird is that you have defined PUPPETDB_KEY and PUPPETDB_CERT
>>> twice, the latter having it set to None which I'm guessing is what
>>> Puppetboard ends up picking.
>>>
>>> However, since your PuppetDB and Puppetboard are hosted on the same
>>> machine you can forgo the whole SSL debacle and use a local, plain
>>> connection instead. Since this traffic will never leave the host people
>>> would need to be logged in to your master to intercept it. Your settings.py
>>> then looks like this:
>>>
>>> PUPPETDB_HOST = 'localhost'
>>> PUPPETDB_PORT = 8080
>>> PUPPETDB_TIMEOUT = 60
>>>
>>> Once that works for you don't forget to change the LOGLEVEL back to
>>> 'info'.
>>>
>>> --
>>> Daniele Sluijters
>>>
>>> On Thursday, 9 October 2014 09:24:08 UTC-7, bluethundr wrote:
>>>
 Hi Daniel,

  Thanks for getting back to me.

 This doesn't look like a configuration error with regard to Puppetboard
> but one with regard

[Puppet Users] Re: Passing Parameters to Powershell

2014-10-09 Thread Juan Andres Ramirez
Example:

I have my script on powershell in the next path

in Puppet:

define some::module() {
   $script = "server1\\shared\\script.ps1

exec { "Executing a script":
  command => "powershell.exe -ExecutionPolicy ByPass -File 
${script} ${param1}",
  unless  => "powershell.exe -ExecutionPolicy ByPass -command 
\"here any command on powershell \""
}



On Thursday, October 9, 2014 4:22:14 PM UTC-3, Paul Ponzeka wrote:
>
> I am using Puppet installed with the powershell module.  I am struggling 
> with how to pass a puppet variable through to powershell.  For instance I 
> have the following in my module *init.pp* file:
>
> class windows_dns(
>
> $forwarders = '1.1.1.1'
>
> ) {
>anchor { 'windows_dns::begin': } ->
>class{'windows_dns::install': } ->
>class{'windows_dns::config': } ->
>class{'windows_dns::service': } ->
>anchor { 'windows_dns::end': }
>
> }
>
>
> Then in my *config.pp* file I have:
>
> class windows_dns::config {
>
> case $kernelmajversion {
> 6.3: {
> $forwarder_execute = 
> 'windows_dns/setdnsforwarders.ps1'
> $forwarder_check = 'windows_dns/checkdnsforwarders.ps1'
> $dnsforwarders = $windows_dns::forwarders
>
> }
> 6.1: {
> $forwarder_execute = 
> 'windows_dns/setdnsforwarders_legacy.ps1'
> $forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1'
>
> }
> }
>
> exec { 'forwarderscreate':
>
> command => template ($forwarder_execute),
> unless => template ($forwarder_check),
> provider => powershell,
> logoutput => true,
>
> }
>
> I have stored as a template in the manifest a powershell script file as:
>
> $dnsforwarders | out-file C:\test.log
>
> I obviously want to use a more complex output.  I tried adding a parameter 
> to the top of my powershell script but dont understand how to pass that as 
> an option to puppet.  
>
> The variable passes through fine.  I tested by changing the command to 
> *command=> 
> template ($dnsforwarders)* and i of course got an error from puppet about 
> it not being able to find the template named *1.1.1.1* in the manifest. 
>  I just dont know how to pass this through to the shell. 
>

-- 
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/c62b8af5-4890-4a84-905e-63e7b6132e13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] custom function error undefined local variable

2014-10-09 Thread Mark Rosedale
Puppet 3.5.1
ruby 1.8.7

Output is:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
undefined local variable or method `dns' for 
# at 
/etc/puppet/modules/vivox/manifests/init.pp:69 on node 
plab5qamaster.vivox.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

On Monday, October 6, 2014 1:47:06 PM UTC-4, Sebastiaan van Steenis wrote:
>
> What version are you running? And what is the output if you try to call 
> the function as you have it now?
>
> On 06 Oct 2014, at 19:07, José Luis Ledesma  > wrote:
>
> Credits go to Nan Liu:
>
> If you are developing facts, it's much easier to just drop into IRB and 
> get everything working there rather than doing round trip debugging between 
> puppet and facter:
>
> irb(main):001:0> require 'facter'
>
> => true
>
> irb(main):002:0> Facter.value("hostname")
>
> => "demo-1"
>
> irb(main):003:0> Facter.value("hostname").split('-')
>
> => ["demo", "1"]
>
> irb(main):006:0>  Facter.add('network_geo') do
>
> irb(main):007:1*   setcode do
>
> irb(main):008:2* hostname_array =  Facter.value(:hostname).split('-')
>
> irb(main):009:2>
>
> irb(main):010:2* # debug info
>
> irb(main):011:2* puts "My network is #{hostname_array}"
>
> irb(main):012:2> hostname_array.first
>
> irb(main):013:2>   end
>
> irb(main):014:1> end
>
> irb(main):015:0> Facter.value(:network_geo)
>
> My network is ["demo", "1"]
>
> => "demo"
>
> If you run your existing fact in irb, you'll see the output is nil instead:
>
> Facter.value(:network_geo)
>
> My network is ["demo", "1"]
>
> => nil
>
> Hth,
> El 06/10/2014 18:07, "Mark Rosedale" > 
> escribió:
>
>> Still haven't been able to hunt down the cause of this issue. Is there a 
>> way to test the code with the puppet wrapping on the cli? 
>>
>> On Friday, October 3, 2014 3:41:57 PM UTC-4, Mark Rosedale wrote:
>>>
>>> Wil, 
>>>
>>> Thanks for the reply. I will look up the module functions you reference. 
>>> Though, part  of this was writing the custom function as a learning 
>>> exercise. 
>>>
>>> So if I have a file with the following in it and run it through ruby it 
>>> works. 
>>>
>>> require 'resolv'
>>> Resolv::DNS.open do |dns|
>>>   ress = dns.getresources "google.com", Resolv::DNS::Resource::IN::A
>>>   if ress.any?
>>> puts dns.getaddress("google.com")
>>>   end
>>> end
>>>
>>> To reference Mike's question. What I found was that 'if ress.any?' works 
>>> and that is what allows me to protect against malformed host names or a 
>>> failure to find an A record. 
>>>
>>> So I've already chopped out the puppet stuff, and this code works. So 
>>> I'm thinking that it must be something with the require statement, where it 
>>> isn't finding the library I need. But I'm not sure what I can do from here. 
>>>
>>> On Friday, October 3, 2014 2:00:27 AM UTC-4, Wil Cooley wrote:


 On Oct 2, 2014 10:23 AM, "Mark Rosedale"  wrote:
 >
 > I have the following custom function that I'm trying to write. 
 >

 Sorry this isn't an answer to your question, but I recently published a 
 module of functions wrapping the standard system get*by* functions (well, 
 wrapping Ruby's interfaces to the standard system functions):  
 https://forge.puppetlabs.com/wcooley/name_service_lookups

 This includes `gethostbyname` and `gethostbyaddr`; the main benefit 
 over querying DNS directly is that it understands nsswitch, so /etc/hosts 
 works and any other host database you might want to use.

 But assuming you want to implement this anyway an exercise in learning 
 Ruby & Puppet extensions, you might start by removing all the Puppet stuff 
 and just get the lookups working as a simple standalone Ruby script.

 Wil

 require 'resolv'
 >
 > module Puppet::Parser::Functions
 >   newfunction(:getIpAddr, :type => :rvalue) do |arguments|
 > Resolv::DNS.open do |dns|
 >   ress = dns.getresources(arguments[0], 
 Resolv::DNS::Resource::IN::A)
 >   if ress.any?
 > dns.getaddress(arguments[0])
 > #break
 >   else
 > raise(Puppet::ParseError, "No valid A Record found for host 
 #{aguments[0]}")
 >   end
 > end
 > #return value
 >   end
 > end
 >
 > I'm getting the following error when I run this function. 
 >
 > Error: Could not retrieve catalog from remote server: Error 400 on 
 SERVER: undefined local variable or method `dns' for 
 # 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...@googlegroups.com.
 > To view this discussion on the web visit https://groups.google.com/d/
 msgid/puppet-users/02de838d-6cb2-495a-883d-98fb15782df9%
 40googlegroups.com.

Re: [Puppet Users] custom function error undefined local variable

2014-10-09 Thread Mark Rosedale
Puppet 3.5.1
ruby 1.8.7

Output is:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
undefined local variable or method `dns' for 
# at 
/etc/puppet/modules/vivox/manifests/init.pp:69 on node xxx
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

On Monday, October 6, 2014 1:47:06 PM UTC-4, Sebastiaan van Steenis wrote:
>
> What version are you running? And what is the output if you try to call 
> the function as you have it now?
>
> On 06 Oct 2014, at 19:07, José Luis Ledesma  > wrote:
>
> Credits go to Nan Liu:
>
> If you are developing facts, it's much easier to just drop into IRB and 
> get everything working there rather than doing round trip debugging between 
> puppet and facter:
>
> irb(main):001:0> require 'facter'
>
> => true
>
> irb(main):002:0> Facter.value("hostname")
>
> => "demo-1"
>
> irb(main):003:0> Facter.value("hostname").split('-')
>
> => ["demo", "1"]
>
> irb(main):006:0>  Facter.add('network_geo') do
>
> irb(main):007:1*   setcode do
>
> irb(main):008:2* hostname_array =  Facter.value(:hostname).split('-')
>
> irb(main):009:2>
>
> irb(main):010:2* # debug info
>
> irb(main):011:2* puts "My network is #{hostname_array}"
>
> irb(main):012:2> hostname_array.first
>
> irb(main):013:2>   end
>
> irb(main):014:1> end
>
> irb(main):015:0> Facter.value(:network_geo)
>
> My network is ["demo", "1"]
>
> => "demo"
>
> If you run your existing fact in irb, you'll see the output is nil instead:
>
> Facter.value(:network_geo)
>
> My network is ["demo", "1"]
>
> => nil
>
> Hth,
> El 06/10/2014 18:07, "Mark Rosedale" > 
> escribió:
>
>> Still haven't been able to hunt down the cause of this issue. Is there a 
>> way to test the code with the puppet wrapping on the cli? 
>>
>> On Friday, October 3, 2014 3:41:57 PM UTC-4, Mark Rosedale wrote:
>>>
>>> Wil, 
>>>
>>> Thanks for the reply. I will look up the module functions you reference. 
>>> Though, part  of this was writing the custom function as a learning 
>>> exercise. 
>>>
>>> So if I have a file with the following in it and run it through ruby it 
>>> works. 
>>>
>>> require 'resolv'
>>> Resolv::DNS.open do |dns|
>>>   ress = dns.getresources "google.com", Resolv::DNS::Resource::IN::A
>>>   if ress.any?
>>> puts dns.getaddress("google.com")
>>>   end
>>> end
>>>
>>> To reference Mike's question. What I found was that 'if ress.any?' works 
>>> and that is what allows me to protect against malformed host names or a 
>>> failure to find an A record. 
>>>
>>> So I've already chopped out the puppet stuff, and this code works. So 
>>> I'm thinking that it must be something with the require statement, where it 
>>> isn't finding the library I need. But I'm not sure what I can do from here. 
>>>
>>> On Friday, October 3, 2014 2:00:27 AM UTC-4, Wil Cooley wrote:


 On Oct 2, 2014 10:23 AM, "Mark Rosedale"  wrote:
 >
 > I have the following custom function that I'm trying to write. 
 >

 Sorry this isn't an answer to your question, but I recently published a 
 module of functions wrapping the standard system get*by* functions (well, 
 wrapping Ruby's interfaces to the standard system functions):  
 https://forge.puppetlabs.com/wcooley/name_service_lookups

 This includes `gethostbyname` and `gethostbyaddr`; the main benefit 
 over querying DNS directly is that it understands nsswitch, so /etc/hosts 
 works and any other host database you might want to use.

 But assuming you want to implement this anyway an exercise in learning 
 Ruby & Puppet extensions, you might start by removing all the Puppet stuff 
 and just get the lookups working as a simple standalone Ruby script.

 Wil

 require 'resolv'
 >
 > module Puppet::Parser::Functions
 >   newfunction(:getIpAddr, :type => :rvalue) do |arguments|
 > Resolv::DNS.open do |dns|
 >   ress = dns.getresources(arguments[0], 
 Resolv::DNS::Resource::IN::A)
 >   if ress.any?
 > dns.getaddress(arguments[0])
 > #break
 >   else
 > raise(Puppet::ParseError, "No valid A Record found for host 
 #{aguments[0]}")
 >   end
 > end
 > #return value
 >   end
 > end
 >
 > I'm getting the following error when I run this function. 
 >
 > Error: Could not retrieve catalog from remote server: Error 400 on 
 SERVER: undefined local variable or method `dns' for 
 # 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...@googlegroups.com.
 > To view this discussion on the web visit https://groups.google.com/d/
 msgid/puppet-users/02de838d-6cb2-495a-883d-98fb15782df9%
 40googlegroups.com.
 > For more options, 

Re: [Puppet Users] Re: Passing Parameters to Powershell

2014-10-09 Thread Josh Cooper
On Thu, Oct 9, 2014 at 12:59 PM, Juan Andres Ramirez 
wrote:

> Example:
>
> I have my script on powershell in the next path
>
> in Puppet:
>
> define some::module() {
>$script = "server1\\shared\\script.ps1
>
> exec { "Executing a script":
>   command => "powershell.exe -ExecutionPolicy ByPass -File
> ${script} ${param1}",
>   unless  => "powershell.exe -ExecutionPolicy ByPass -command
> \"here any command on powershell \""
> }
>
>
>
> On Thursday, October 9, 2014 4:22:14 PM UTC-3, Paul Ponzeka wrote:
>
>> I am using Puppet installed with the powershell module.  I am struggling
>> with how to pass a puppet variable through to powershell.  For instance I
>> have the following in my module *init.pp* file:
>>
>> class windows_dns(
>>
>> $forwarders = '1.1.1.1'
>>
>> ) {
>>anchor { 'windows_dns::begin': } ->
>>class{'windows_dns::install': } ->
>>class{'windows_dns::config': } ->
>>class{'windows_dns::service': } ->
>>anchor { 'windows_dns::end': }
>>
>> }
>>
>>
>> Then in my *config.pp* file I have:
>>
>> class windows_dns::config {
>>
>> case $kernelmajversion {
>> 6.3: {
>> $forwarder_execute =
>> 'windows_dns/setdnsforwarders.ps1'
>> $forwarder_check = 'windows_dns/checkdnsforwarders.ps1'
>> $dnsforwarders = $windows_dns::forwarders
>>
>> }
>> 6.1: {
>> $forwarder_execute =
>> 'windows_dns/setdnsforwarders_legacy.ps1'
>> $forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1'
>>
>> }
>> }
>>
>> exec { 'forwarderscreate':
>>
>> command => template ($forwarder_execute),
>> unless => template ($forwarder_check),
>> provider => powershell,
>> logoutput => true,
>>
>> }
>>
>> I have stored as a template in the manifest a powershell script file as:
>>
>> $dnsforwarders | out-file C:\test.log
>>
>> I obviously want to use a more complex output.  I tried adding a
>> parameter to the top of my powershell script but dont understand how to
>> pass that as an option to puppet.
>>
>> The variable passes through fine.  I tested by changing the command to 
>> *command=>
>> template ($dnsforwarders)* and i of course got an error from puppet
>> about it not being able to find the template named *1.1.1.1* in the
>> manifest.  I just dont know how to pass this through to the shell.
>>
>  --
> 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/c62b8af5-4890-4a84-905e-63e7b6132e13%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>


I would recommend using the powershell provider as you were doing. In your
powershell script 'windows_dns/setdnsforwarders.ps1', resolve parameters
using ERB syntax found in
https://docs.puppetlabs.com/guides/templating.html#referencing-variables,
something like:

<%= scope['dnsforwarders'] %>

Josh

-- 
Josh Cooper
Developer, Puppet Labs

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


Re: [Puppet Users] Re: Passing Parameters to Powershell

2014-10-09 Thread Paul Ponzeka
Thanks josh, so in my template file setdnsforwarders.ps1 is this the 
correct syntax?

$outside = <%= scope['dnsforwarders'] %>
$outside | out-file C:\output.log -append


On Thursday, October 9, 2014 4:52:04 PM UTC-4, Josh Cooper wrote:
>
>
>
> On Thu, Oct 9, 2014 at 12:59 PM, Juan Andres Ramirez  > wrote:
>
>> Example:
>>
>> I have my script on powershell in the next path
>>
>> in Puppet:
>>
>> define some::module() {
>>$script = "server1\\shared\\script.ps1
>> 
>> exec { "Executing a script":
>>   command => "powershell.exe -ExecutionPolicy ByPass -File 
>> ${script} ${param1}",
>>   unless  => "powershell.exe -ExecutionPolicy ByPass -command 
>> \"here any command on powershell \""
>> }
>>
>>
>>
>> On Thursday, October 9, 2014 4:22:14 PM UTC-3, Paul Ponzeka wrote:
>>
>>> I am using Puppet installed with the powershell module.  I am struggling 
>>> with how to pass a puppet variable through to powershell.  For instance I 
>>> have the following in my module *init.pp* file:
>>>
>>> class windows_dns(
>>>
>>> $forwarders = '1.1.1.1'
>>>
>>> ) {
>>>anchor { 'windows_dns::begin': } ->
>>>class{'windows_dns::install': } ->
>>>class{'windows_dns::config': } ->
>>>class{'windows_dns::service': } ->
>>>anchor { 'windows_dns::end': }
>>>
>>> }
>>>
>>>
>>> Then in my *config.pp* file I have:
>>>
>>> class windows_dns::config {
>>>
>>> case $kernelmajversion {
>>> 6.3: {
>>> $forwarder_execute = 
>>> 'windows_dns/setdnsforwarders.ps1'
>>> $forwarder_check = 'windows_dns/checkdnsforwarders.ps1'
>>> $dnsforwarders = $windows_dns::forwarders
>>>
>>> }
>>> 6.1: {
>>> $forwarder_execute = 
>>> 'windows_dns/setdnsforwarders_legacy.ps1'
>>> $forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1'
>>>
>>> }
>>> }
>>>
>>> exec { 'forwarderscreate':
>>>
>>> command => template ($forwarder_execute),
>>> unless => template ($forwarder_check),
>>> provider => powershell,
>>> logoutput => true,
>>>
>>> }
>>>
>>> I have stored as a template in the manifest a powershell script file as:
>>>
>>> $dnsforwarders | out-file C:\test.log
>>>
>>> I obviously want to use a more complex output.  I tried adding a 
>>> parameter to the top of my powershell script but dont understand how to 
>>> pass that as an option to puppet.  
>>>
>>> The variable passes through fine.  I tested by changing the command to 
>>> *command=> 
>>> template ($dnsforwarders)* and i of course got an error from puppet 
>>> about it not being able to find the template named *1.1.1.1* in the 
>>> manifest.  I just dont know how to pass this through to the shell. 
>>>
>>  -- 
>> 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 .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/puppet-users/c62b8af5-4890-4a84-905e-63e7b6132e13%40googlegroups.com
>>  
>> 
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> I would recommend using the powershell provider as you were doing. In your 
> powershell script 'windows_dns/setdnsforwarders.ps1', resolve parameters 
> using ERB syntax found in 
> https://docs.puppetlabs.com/guides/templating.html#referencing-variables, 
> something like:
>
> <%= scope['dnsforwarders'] %>
>
> Josh
>
> -- 
> Josh Cooper
> Developer, Puppet Labs
>  

-- 
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/961dd225-1159-48fe-a9bf-c727bf094b74%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Need help with simple hiera example

2014-10-09 Thread Stack Kororā

Wow! Thanks for the responses John!

> On Thursday, October 9, 2014 8:52:00 AM UTC-5, jcbollinger wrote:
> If the master had successfully looked up your datum then the result would
> have been as you expected.  The behavior you present is characteristic of
> (and well documented for) the case where the automatic lookup fails,
> leaving the master to fall back to the default value given in the class
> definition.  The problem is not in your Puppet manifests, and your CLI
> tests demonstrate that it is not in your data themselves, but those are 
not
> the only possibilities.

If it isn't hiera and it isn't puppet, what other possibilities are there? 
Any idea on how I can debug this better? I would love to see in the puppet 
logs something like "found a variable with no definition, looking up in 
hiera in this file...nope didn't find it...trying this other file...ah 
found it" but I haven't seen anything on how to better troubleshoot /how/ 
puppet is determining if a variable is in hiera or not.
 

> How's hiera involved in that?  You now have $test as an uninitialized 
local
> variable (no longer a class parameter).  It expands to nothing when you
> interpolate it into your filename, so you're managing File["/tmp/"], which
> is equivalent to File["/tmp"].  That file (directory) already exists, and
> that's all you ask Puppet to ensure, so Puppet does nothing.

Wow. That totally makes sense. I was under the impression (very likely a 
mistaken impression apparently) that puppet would look at $test, not find 
anything in it, and then do look up in hiera for the full scope of the 
variable (aka: class::variable -> testhiera::test). So this explains that 
some of the "oddity" i've seen is just a misunderstanding of the 
documentation. Thanks for pointing that out!


On Thursday, October 9, 2014 9:36:38 AM UTC-5, jcbollinger wrote:
>> $bar = hiera('myfoo::bar', 'defaultvalue')
>> However, the puppet docs basically say do this for 2.7 but not for 3+
>> [ https://docs.puppetlabs.com/hiera/1/puppet.html ].

> In Puppet 2, that was the only way you could do it.  After Puppet 3 was
> released, it was common for module authors to attempt to support both P2 
and
> P3, which tied them to that form.  Even with official support for the P2
> series ending, there is probably still interest in compatibility from some
> quarters.
>
> As for using only automatic parameter binding in P3, that's basically a 
code
> style argument, its position right in the documentation notwithstanding.  
The
> advice is not bad as far as it goes, but do note that it also presents an
> apparently acceptable (albeit downplayed) alternative: explicitly document
> the hiera keys your class uses.  It seems like you've probably been around
> enough to see a code-style war or two, so I'll leave it there.

OK. So it isn't going to cause me problems, it is just backwards 
compatibility and/or a code style choice. Then in that case, I may start 
using it just so that I have it explicitly called for my own use when I 
look at the code in 6 months. :-)

 
[snip]

>> 1.2) class myclass ($parameter_one = "default text") { ...content => 
$parameter_one, ...}
>> [...] will /always/ go to 'default text' for me. It has yet to pull back 
the
>> hiera data.

> If that's true then something is dreadfully wrong in your environment.

Hrm...that's not good. But this test VM is a very new build of Scientific 
Linux 6.5 with the latest puppet. I really haven't made many changes. Not 
sure what I could have goofed on it. Any suggestions for debugging what is 
wrong? I mean nothing is really being kicked out in the log files (but that 
doesn't mean there isn't a problem).

> Class parameter defaults do not interfere with automated data binding.
> Puppet's automated test suite verifies this, so if you're seeing different
> behavior then there is some sort of local modification or environment 
issue
> that is causing breakage.  I hope you'll forgive me if I judge it more 
likely
> that your tests are misleading you.

No worries. I get it. Chances are much more likely I goofed something up. I 
just don't know what. :-)


>> 2) $ cat modules/testhiera/manifests/init.pp
>>  class testhiera ( $test = $hieratest::test ) {
>>  file { "/tmp/$test" : ensure => present}
>>  }

> How is that different from your 1.2, which you say doesn't work?

Not sure i understand your question. The 1.2 that doesn't work I am setting 
a default value in hopes that the hiera value is taken. In this example, I 
am explicitly calling the hiera value...Now functionally it may be the same 
(or at least it is supposed to be), but that isn't how I see it behave.

> It seems like you may have a misconception: automated data binding applies
> specifically to class parameters, as an aspect of resolving their 
values.  It
> does not apply to class variables that are not parameters, and it is not
> automagically applied to parameters of classes that have not yet been 
evaluated.
>
> Your co

[Puppet Users] Re: Need help with simple hiera example

2014-10-09 Thread Stack Kororā

On Thursday, October 9, 2014 12:49:40 PM UTC-5, Tony Thayer wrote:
> Couple of things I noticed:
> Your testhiera/manifests/init.pp file looks a little odd. I re-wrote it a 
bit and it ran without a hitch.
> class testhiera {
>   $test = hiera('testhiera::test')
>   notice("Test is ${test}")
>   file { "/tmp/${test}" :
>   ensure => present,
>   }
> }
>
> But keep in mind that I am leaning entirely on hiera in my environment. My
> site.pp file only contains hiera_include('classes') (and some other stuff 
to
> omit .svn/.git directories from being backed up).
> My personal take is that you should go all or nothing with it. That way 
you
> aren't maintaining node definitions in site.pp AND in your node .yaml 
files.
>- Tony

Thanks for the code fix! I would like to get to the point where all of the 
data is in hiera. But I have a pretty big environment and unfortunately it 
was one of those 'Boy, that escalated quickly' deals. It started off as 
'Hey this puppet thing is cool!' and quickly tumbled into 5 sys-admins 
hacking/patching code together for their servers. A few months ago I really 
started to clean things up when I realized that an average puppet run was 
about 10 minutes...I fixed a few big things and re-wrote one module so now 
it is down to about 3 minutes but that is still far too long for what is 
going on. The more I looked at that code the more I really began dreading 
to look at the next module. Now that we have trimmed the number of OS's we 
support to just CentOS 5&6, Scientific Linux 5&6, RHEL 6, and SLES11, there 
is a /lot/ of dead puppet code for all the weird hacks we had to do. I want 
to rip all of that out too!

The point being, I can't just flip a switch and use hiera off the bat. This 
is going to be a tedious process as I switch out one module at a time with 
a re-write. So I need to make sure I do this right and balance things 
properly. This is also the biggest reason why I worry about a variable not 
being found and Puppet silently carrying on without telling anyone that 
there is a problem. The good thing is that I have a mostly-complete dev 
virtual environment on my laptop, plus a much-closer-to-production dev 
virtual environment at work, plus a good sampling of 'production boxes we 
can afford to test on' (and I test code in that order). So by the time we 
are ready to push to proper prod, things VERY rarely go completely sideways 
on us.

I really like the idea of one place to control the specific variables 
needed for a host and I /really/ like the idea of having our modules in 
such a manner that we can just hand that code over to someone without 
worrying about sensitive data in them (even if no one would ever use those 
modules...a lot of them are very specific to our environment but I still 
don't want that kind of information in them). So I think this is a good 
goal for me to move forward to. It just will take some time. :-)

~Stack~

-- 
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/0ba936d6-dfed-4ba0-b8f6-7e2790975b26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] puppet-jobs list?

2014-10-09 Thread sorthum
Howdy.

A cursory google search hasn't turned up much on this topic. 

Is there a puppet-jobs list for jobs oriented around Puppet (not to be 
confused with "Work at Puppet Labs!" style stuff?

Other projects seem to have similar lists, but I can't find one for Puppet; 
I suspect it'd be constructive to have a place to throw a few Puppet 
projects to the community without spamming the users list.

-- 
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/be5c6dc1-9da5-4076-9bdf-62c494a5b406%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: puppetboard unable to reach puppetb

2014-10-09 Thread Ken Barber
>> Are you pushing reports into puppetdb or only into foreman?
>
>
>
> Ok so I missed that. Sorry dude. And yeah as you point out I originally had
> reports only going to foreman. But I changed the puppet.conf to this:
>
> [root@puppet:/etc/puppet] #egrep -i "reports|storeconfigs" puppet.conf
> reports= foreman puppetdb
> storeconfigs = true
> storeconfigs_backend = puppetdb
>
>
> I wasn't sure if this was supposed to be comma dlimeted or space. I tried
> using a space between the two.
>
> And so far no change.
>
> http://puppetboard.jokefire.com/

Its a comma, if you are unclear. Try it again and restart your puppet
master. Then check your PuppetDB logs (/var/log/puppetdb/puppetdb.log)
you should see logged commands for the 'store report' command be
submitted on a node after you do an agent run, if not - check your
puppet master logs to see if its logging any errors with sending the
reports. The puppet master usually logs to syslog FYI. Basically these
'store report' commands should be submitted in order from one host
like so:

* replace facts
* replace catalog
* store report

If none of that helps, we can explore turning on debug mode for Puppet
to see what's being logged.

ken.

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


Re: [Puppet Users] puppet-jobs list?

2014-10-09 Thread Ken Barber
> A cursory google search hasn't turned up much on this topic.
>
> Is there a puppet-jobs list for jobs oriented around Puppet (not to be
> confused with "Work at Puppet Labs!" style stuff?
>
> Other projects seem to have similar lists, but I can't find one for Puppet;
> I suspect it'd be constructive to have a place to throw a few Puppet
> projects to the community without spamming the users list.

Howdy, a list moderator here. We don't have a formal list, the only
thing I can speak to is perhaps LinkedIn, which seems to be a popular
place. Perhaps others can chime in about what's available in the
industry if you can supply a location. Having said that, if all you
want to do is post a job for a company you actually work for then
thats fine if you are an active member of the list, or your members of
your company are. The rules are simple:

"Recruiters are not permitted to post jobs to our mailing lists.
However, if you are an active community member and you are personally
hiring more people to work on Puppet, you may post relevant job
descriptions."

We try to be pragmatic about it obviously, and this is largely in
response to our users needs rather than any hard and fast rules
because this list is primarily about helping community members not
about commerce. Others have voiced concerns in the past about
recruiters, and its our responsibility to maintain that.

That means basically don't be annoying about it :-). I'd suggest
looking through the list archives to see the 'tone' that others try to
set when advertising jobs for their companies to get a feel for the
rough expectations. Most people put [JOB] in the title to designate it
as such.

Full details of our guidelines and the quote I supplied above are here FYI:

https://docs.puppetlabs.com/community/community_guidelines.html#mailing-list-guidelines

ken.

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


Re: [Puppet Users] puppet-jobs list?

2014-10-09 Thread sorthum
Thanks, Ken. Will post something shortly; I appreciate the response!


On Thursday, October 9, 2014 4:02:26 PM UTC-7, Ken Barber wrote:
>
> > A cursory google search hasn't turned up much on this topic. 
> > 
> > Is there a puppet-jobs list for jobs oriented around Puppet (not to be 
> > confused with "Work at Puppet Labs!" style stuff? 
> > 
> > Other projects seem to have similar lists, but I can't find one for 
> Puppet; 
> > I suspect it'd be constructive to have a place to throw a few Puppet 
> > projects to the community without spamming the users list. 
>
> Howdy, a list moderator here. We don't have a formal list, the only 
> thing I can speak to is perhaps LinkedIn, which seems to be a popular 
> place. Perhaps others can chime in about what's available in the 
> industry if you can supply a location. Having said that, if all you 
> want to do is post a job for a company you actually work for then 
> thats fine if you are an active member of the list, or your members of 
> your company are. The rules are simple: 
>
> "Recruiters are not permitted to post jobs to our mailing lists. 
> However, if you are an active community member and you are personally 
> hiring more people to work on Puppet, you may post relevant job 
> descriptions." 
>
> We try to be pragmatic about it obviously, and this is largely in 
> response to our users needs rather than any hard and fast rules 
> because this list is primarily about helping community members not 
> about commerce. Others have voiced concerns in the past about 
> recruiters, and its our responsibility to maintain that. 
>
> That means basically don't be annoying about it :-). I'd suggest 
> looking through the list archives to see the 'tone' that others try to 
> set when advertising jobs for their companies to get a feel for the 
> rough expectations. Most people put [JOB] in the title to designate it 
> as such. 
>
> Full details of our guidelines and the quote I supplied above are here 
> FYI: 
>
>
> https://docs.puppetlabs.com/community/community_guidelines.html#mailing-list-guidelines
>  
>
> ken. 
>

-- 
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/652da68d-07f3-468f-bebb-22a7be683aff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: Passing Parameters to Powershell

2014-10-09 Thread Paul Ponzeka
I tried that and it just came up blank.  Am I suppose to pass it as a 
powershell parameter?

On Thursday, October 9, 2014 5:18:05 PM UTC-4, Paul Ponzeka wrote:
>
> Thanks josh, so in my template file setdnsforwarders.ps1 is this the 
> correct syntax?
>
> $outside = <%= scope['dnsforwarders'] %>
> $outside | out-file C:\output.log -append
>
>
> On Thursday, October 9, 2014 4:52:04 PM UTC-4, Josh Cooper wrote:
>>
>>
>>
>> On Thu, Oct 9, 2014 at 12:59 PM, Juan Andres Ramirez  
>> wrote:
>>
>>> Example:
>>>
>>> I have my script on powershell in the next path
>>>
>>> in Puppet:
>>>
>>> define some::module() {
>>>$script = "server1\\shared\\script.ps1
>>> 
>>> exec { "Executing a script":
>>>   command => "powershell.exe -ExecutionPolicy ByPass -File 
>>> ${script} ${param1}",
>>>   unless  => "powershell.exe -ExecutionPolicy ByPass 
>>> -command \"here any command on powershell \""
>>> }
>>>
>>>
>>>
>>> On Thursday, October 9, 2014 4:22:14 PM UTC-3, Paul Ponzeka wrote:
>>>
 I am using Puppet installed with the powershell module.  I am 
 struggling with how to pass a puppet variable through to powershell.  For 
 instance I have the following in my module *init.pp* file:

 class windows_dns(

 $forwarders = '1.1.1.1'

 ) {
anchor { 'windows_dns::begin': } ->
class{'windows_dns::install': } ->
class{'windows_dns::config': } ->
class{'windows_dns::service': } ->
anchor { 'windows_dns::end': }

 }


 Then in my *config.pp* file I have:

 class windows_dns::config {

 case $kernelmajversion {
 6.3: {
 $forwarder_execute = 
 'windows_dns/setdnsforwarders.ps1'
 $forwarder_check = 'windows_dns/checkdnsforwarders.ps1'
 $dnsforwarders = $windows_dns::forwarders

 }
 6.1: {
 $forwarder_execute = 
 'windows_dns/setdnsforwarders_legacy.ps1'
 $forwarder_check = 'windows_dns/checkdnsforwarders_legacy.ps1'

 }
 }

 exec { 'forwarderscreate':

 command => template ($forwarder_execute),
 unless => template ($forwarder_check),
 provider => powershell,
 logoutput => true,

 }

 I have stored as a template in the manifest a powershell script file as:

 $dnsforwarders | out-file C:\test.log

 I obviously want to use a more complex output.  I tried adding a 
 parameter to the top of my powershell script but dont understand how to 
 pass that as an option to puppet.  

 The variable passes through fine.  I tested by changing the command to 
 *command=> 
 template ($dnsforwarders)* and i of course got an error from puppet 
 about it not being able to find the template named *1.1.1.1* in the 
 manifest.  I just dont know how to pass this through to the shell. 

>>>  -- 
>>> 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.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/puppet-users/c62b8af5-4890-4a84-905e-63e7b6132e13%40googlegroups.com
>>>  
>>> 
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> I would recommend using the powershell provider as you were doing. In 
>> your powershell script 'windows_dns/setdnsforwarders.ps1', resolve 
>> parameters using ERB syntax found in 
>> https://docs.puppetlabs.com/guides/templating.html#referencing-variables, 
>> something like:
>>
>> <%= scope['dnsforwarders'] %>
>>
>> Josh
>>
>> -- 
>> Josh Cooper
>> Developer, Puppet Labs
>>  
>

-- 
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/e7cfb152-18d3-43df-a782-b69eee1f83ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] augeas, sshd and multiple onlyif requirements

2014-10-09 Thread Chris

Hi all,

I'm trying to insert a ClientAliveInterval setting into sshd_config with 
augeas. Some servers have a "Match User" line (so the new setting needs 
to come before the "Match User" line), and some don't. Some already have 
a ClientAliveInterval setting, and some don't.


My first attempt was this:

augeas{'sshd-config-client-alive-interval':
  context => '/files/etc/ssh/sshd_config',
  changes => [
'ins ClientAliveInterval before Match',
'set ClientAliveInterval 3600',
  ],
  onlyif => [
'match ClientAliveInterval size == 0',
'match Match size > 0',
  ],
}

But it's not checking both onlyif requirements before trying to add the 
new setting. Reversing the order tries to add it to configs with the 
option already set which also causes a failure.



I've read a few posts that suggest putting both match requirements into 
one setting, but I can't get the syntax right.


augeas{'sshd-config-client-alive-interval':
  context => '/files/etc/ssh/sshd_config',
  changes => [
'ins ClientAliveInterval before Match',
'set ClientAliveInterval 3600',
  ],
  onlyif => [
'match "/files/etc/ssh/sshd_config[(match 
/files/etc/ssh/sshd_config include ClientAliveInterval) size == 0 and 
(match /files/etc/ssh/sshd_config include Match) size > 0]" size > 0',

  ],
}

Any help, suggestions, alternatives would be greatly appreciated.

Using augeas 1.0.0 from scientific linux 6, puppet 2.7.

Thanks!
--
Postgresql & php tutorials
http://www.designmagick.com/

--
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/543745AC.80108%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] Re: puppetboard unable to reach puppetb

2014-10-09 Thread Tim Dunphy
Hi Ken,


> Its a comma, if you are unclear.


Yep! I was able to get that by trying it out. But thanks for the feedback!
Always extremely welcomed!

[root@puppet:~] #cd /etc/puppet
[root@puppet:/etc/puppet] #grep reports puppet.conf
reports= foreman, puppetdb

Try it again and restart your puppet
> master. Then check your PuppetDB logs (/var/log/puppetdb/puppetdb.log)
> you should see logged commands for the 'store report' command be
> submitted on a node after you do an agent run


Seems to be working fine! I can see reports turning up both in foreman and
in puppetboard now. BTW, I'm really liking both the foreman and the
puppeboard. I'm glad I put in the effort to get both it and the puppetdb
working. I'm going to pitch the puppetdb to my coworkers who so far only
use the community version of puppet with no web interface. Masochists,
clearly!

Thanks again!
Tim




> Try it again and restart your puppet
> master. Then check your PuppetDB logs (/var/log/puppetdb/puppetdb.log)
> you should see logged commands for the 'store report' command be
> submitted on a node after you do an agent run


On Thu, Oct 9, 2014 at 6:52 PM, Ken Barber  wrote:

> >> Are you pushing reports into puppetdb or only into foreman?
> >
> >
> >
> > Ok so I missed that. Sorry dude. And yeah as you point out I originally
> had
> > reports only going to foreman. But I changed the puppet.conf to this:
> >
> > [root@puppet:/etc/puppet] #egrep -i "reports|storeconfigs" puppet.conf
> > reports= foreman puppetdb
> > storeconfigs = true
> > storeconfigs_backend = puppetdb
> >
> >
> > I wasn't sure if this was supposed to be comma dlimeted or space. I tried
> > using a space between the two.
> >
> > And so far no change.
> >
> > http://puppetboard.jokefire.com/
>
> Its a comma, if you are unclear. Try it again and restart your puppet
> master. Then check your PuppetDB logs (/var/log/puppetdb/puppetdb.log)
> you should see logged commands for the 'store report' command be
> submitted on a node after you do an agent run, if not - check your
> puppet master logs to see if its logging any errors with sending the
> reports. The puppet master usually logs to syslog FYI. Basically these
> 'store report' commands should be submitted in order from one host
> like so:
>
> * replace facts
> * replace catalog
> * store report
>
> If none of that helps, we can explore turning on debug mode for Puppet
> to see what's being logged.
>
> ken.
>
> --
> 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/CAE4bNT%3DsYszRgMm_eBWqvkDH8UsZnEB06knoQZT4r_pjWx2X2w%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
GPG me!!

gpg --keyserver pool.sks-keyservers.net --recv-keys F186197B

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


[Puppet Users] Identifying file content change in subsequent client run

2014-10-09 Thread ganesh634


How can i identify if the file content is changed in subsequent client run.
Need this information for new resource implementation, which will take 
action
only if file contents are modified.
The file will be created on client using template resource.

Is there a way to cache information of previous client run if the client is 
running in cron mode.


-- 
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/f8b3cae1-c10f-483c-83e6-aebb664c66f8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] augeas, sshd and multiple onlyif requirements

2014-10-09 Thread John Warburton
On 10 October 2014 13:34, Chris  wrote:

>
> Any help, suggestions, alternatives would be greatly appreciated.
>

Stop using Augeas and start using templates


Here's an extreme example from the the most popular SSH module
 on the forge -
https://github.com/saz/puppet-ssh/blob/master/templates/sshd_config.erb,
although I find Garrett's easier to read if you were new to templating -
https://github.com/ghoneycutt/puppet-module-ssh/blob/master/templates/sshd_config.erb

John

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


Re: [Puppet Users] Identifying file content change in subsequent client run

2014-10-09 Thread Ashish Jaiswal

Hi,

You can check for the mtime in file resource.

On Friday 10 October 2014 10:50 AM, ganesh634 wrote:



How can i identify if the file content is changed in subsequent client 
run.
Need this information for new resource implementation, which will take 
action

only if file contents are modified.
The file will be created on client using template resource.

Is there a way to cache information of previous client run if the 
client is running in cron mode.



--
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/f8b3cae1-c10f-483c-83e6-aebb664c66f8%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/543771D1.6040800%40gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Identifying file content change in subsequent client run

2014-10-09 Thread ganesh634
Thanks for your reply.
In that case i need to cache the mtime for file and on subsequent client run
need to check if mtime is same or not.
How to cache this information for client running in cron mode.
Is there a way to save context of previous client run.

On Friday, 10 October 2014 10:50:58 UTC+5:30, ganesh634 wrote:
>
>
>
> How can i identify if the file content is changed in subsequent client run.
> Need this information for new resource implementation, which will take 
> action
> only if file contents are modified.
> The file will be created on client using template resource.
>
> Is there a way to cache information of previous client run if the client 
> is running in cron mode.
>
>
>

-- 
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/489716ef-08f0-4c65-ac7a-224ddf61f5a0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] custom function error undefined local variable

2014-10-09 Thread Sebastiaan van Steenis
I cannot reproduce your error, but your function does conflict with some 
internals I guess. I have some other modules failing when I use your function. 
If I simplify your function 
(https://gist.github.com/superseb/fdb443e86a8470a276a5) it works just fine. 
What other modules and/or custom functions are in your module path? Could you 
try using only the module with this custom function and see how that goes? 
Don't forget to restart the Puppetmaster if you are changing functions.

On 09 Oct 2014, at 22:10, Mark Rosedale  wrote:

> Puppet 3.5.1
> ruby 1.8.7
> 
> Output is:
> 
> Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
> undefined local variable or method `dns' for 
> # at 
> /etc/puppet/modules/vivox/manifests/init.pp:69 on node xxx
> Warning: Not using cache on failed catalog
> Error: Could not retrieve catalog; skipping run
> 
> On Monday, October 6, 2014 1:47:06 PM UTC-4, Sebastiaan van Steenis wrote:
> What version are you running? And what is the output if you try to call the 
> function as you have it now?
> 
> On 06 Oct 2014, at 19:07, José Luis Ledesma  wrote:
> 
>> Credits go to Nan Liu:
>> 
>> If you are developing facts, it's much easier to just drop into IRB and get 
>> everything working there rather than doing round trip debugging between 
>> puppet and facter:
>> 
>> irb(main):001:0> require 'facter'
>> 
>> => true
>> 
>> irb(main):002:0> Facter.value("hostname")
>> 
>> => "demo-1"
>> 
>> irb(main):003:0> Facter.value("hostname").split('-')
>> 
>> => ["demo", "1"]
>> 
>> irb(main):006:0>  Facter.add('network_geo') do
>> 
>> irb(main):007:1*   setcode do
>> 
>> irb(main):008:2* hostname_array =  Facter.value(:hostname).split('-')
>> 
>> irb(main):009:2>
>> 
>> irb(main):010:2* # debug info
>> 
>> irb(main):011:2* puts "My network is #{hostname_array}"
>> 
>> irb(main):012:2> hostname_array.first
>> 
>> irb(main):013:2>   end
>> 
>> irb(main):014:1> end
>> 
>> irb(main):015:0> Facter.value(:network_geo)
>> 
>> My network is ["demo", "1"]
>> 
>> => "demo"
>> 
>> If you run your existing fact in irb, you'll see the output is nil instead:
>> 
>> Facter.value(:network_geo)
>> 
>> My network is ["demo", "1"]
>> 
>> => nil
>> 
>> Hth,
>> 
>> El 06/10/2014 18:07, "Mark Rosedale"  escribió:
>> Still haven't been able to hunt down the cause of this issue. Is there a way 
>> to test the code with the puppet wrapping on the cli? 
>> 
>> On Friday, October 3, 2014 3:41:57 PM UTC-4, Mark Rosedale wrote:
>> Wil, 
>> 
>> Thanks for the reply. I will look up the module functions you reference. 
>> Though, part  of this was writing the custom function as a learning 
>> exercise. 
>> 
>> So if I have a file with the following in it and run it through ruby it 
>> works. 
>> 
>> require 'resolv'
>> Resolv::DNS.open do |dns|
>>   ress = dns.getresources "google.com", Resolv::DNS::Resource::IN::A
>>   if ress.any?
>> puts dns.getaddress("google.com")
>>   end
>> end
>> 
>> To reference Mike's question. What I found was that 'if ress.any?' works and 
>> that is what allows me to protect against malformed host names or a failure 
>> to find an A record. 
>> 
>> So I've already chopped out the puppet stuff, and this code works. So I'm 
>> thinking that it must be something with the require statement, where it 
>> isn't finding the library I need. But I'm not sure what I can do from here. 
>> 
>> On Friday, October 3, 2014 2:00:27 AM UTC-4, Wil Cooley wrote:
>> 
>> On Oct 2, 2014 10:23 AM, "Mark Rosedale"  wrote:
>> >
>> > I have the following custom function that I'm trying to write. 
>> >
>> 
>> Sorry this isn't an answer to your question, but I recently published a 
>> module of functions wrapping the standard system get*by* functions (well, 
>> wrapping Ruby's interfaces to the standard system functions):  
>> https://forge.puppetlabs.com/wcooley/name_service_lookups
>> 
>> This includes `gethostbyname` and `gethostbyaddr`; the main benefit over 
>> querying DNS directly is that it understands nsswitch, so /etc/hosts works 
>> and any other host database you might want to use.
>> 
>> But assuming you want to implement this anyway an exercise in learning Ruby 
>> & Puppet extensions, you might start by removing all the Puppet stuff and 
>> just get the lookups working as a simple standalone Ruby script.
>> 
>> Wil
>> 
>> require 'resolv'
>> >
>> > module Puppet::Parser::Functions
>> >   newfunction(:getIpAddr, :type => :rvalue) do |arguments|
>> > Resolv::DNS.open do |dns|
>> >   ress = dns.getresources(arguments[0], Resolv::DNS::Resource::IN::A)
>> >   if ress.any?
>> > dns.getaddress(arguments[0])
>> > #break
>> >   else
>> > raise(Puppet::ParseError, "No valid A Record found for host 
>> > #{aguments[0]}")
>> >   end
>> > end
>> > #return value
>> >   end
>> > end
>> >
>> > I'm getting the following error when I run this function. 
>> >
>> > Error: Could not retrieve catalog from remote server: Error 400 on

Re: [Puppet Users] custom function error undefined local variable

2014-10-09 Thread Sebastiaan van Steenis
Second thought, could you show the init.pp file in vivox/manifests ? Or just 
the relevant parts around line 69?

On 10 Oct 2014, at 08:10, Sebastiaan van Steenis  wrote:

> I cannot reproduce your error, but your function does conflict with some 
> internals I guess. I have some other modules failing when I use your 
> function. If I simplify your function 
> (https://gist.github.com/superseb/fdb443e86a8470a276a5) it works just fine. 
> What other modules and/or custom functions are in your module path? Could you 
> try using only the module with this custom function and see how that goes? 
> Don't forget to restart the Puppetmaster if you are changing functions.
> 
> On 09 Oct 2014, at 22:10, Mark Rosedale  wrote:
> 
>> Puppet 3.5.1
>> ruby 1.8.7
>> 
>> Output is:
>> 
>> Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
>> undefined local variable or method `dns' for 
>> # at 
>> /etc/puppet/modules/vivox/manifests/init.pp:69 on node xxx
>> Warning: Not using cache on failed catalog
>> Error: Could not retrieve catalog; skipping run
>> 
>> On Monday, October 6, 2014 1:47:06 PM UTC-4, Sebastiaan van Steenis wrote:
>> What version are you running? And what is the output if you try to call the 
>> function as you have it now?
>> 
>> On 06 Oct 2014, at 19:07, José Luis Ledesma  wrote:
>> 
>>> Credits go to Nan Liu:
>>> 
>>> If you are developing facts, it's much easier to just drop into IRB and get 
>>> everything working there rather than doing round trip debugging between 
>>> puppet and facter:
>>> 
>>> irb(main):001:0> require 'facter'
>>> 
>>> => true
>>> 
>>> irb(main):002:0> Facter.value("hostname")
>>> 
>>> => "demo-1"
>>> 
>>> irb(main):003:0> Facter.value("hostname").split('-')
>>> 
>>> => ["demo", "1"]
>>> 
>>> irb(main):006:0>  Facter.add('network_geo') do
>>> 
>>> irb(main):007:1*   setcode do
>>> 
>>> irb(main):008:2* hostname_array =  Facter.value(:hostname).split('-')
>>> 
>>> irb(main):009:2>
>>> 
>>> irb(main):010:2* # debug info
>>> 
>>> irb(main):011:2* puts "My network is #{hostname_array}"
>>> 
>>> irb(main):012:2> hostname_array.first
>>> 
>>> irb(main):013:2>   end
>>> 
>>> irb(main):014:1> end
>>> 
>>> irb(main):015:0> Facter.value(:network_geo)
>>> 
>>> My network is ["demo", "1"]
>>> 
>>> => "demo"
>>> 
>>> If you run your existing fact in irb, you'll see the output is nil instead:
>>> 
>>> Facter.value(:network_geo)
>>> 
>>> My network is ["demo", "1"]
>>> 
>>> => nil
>>> 
>>> Hth,
>>> 
>>> El 06/10/2014 18:07, "Mark Rosedale"  escribió:
>>> Still haven't been able to hunt down the cause of this issue. Is there a 
>>> way to test the code with the puppet wrapping on the cli? 
>>> 
>>> On Friday, October 3, 2014 3:41:57 PM UTC-4, Mark Rosedale wrote:
>>> Wil, 
>>> 
>>> Thanks for the reply. I will look up the module functions you reference. 
>>> Though, part  of this was writing the custom function as a learning 
>>> exercise. 
>>> 
>>> So if I have a file with the following in it and run it through ruby it 
>>> works. 
>>> 
>>> require 'resolv'
>>> Resolv::DNS.open do |dns|
>>>   ress = dns.getresources "google.com", Resolv::DNS::Resource::IN::A
>>>   if ress.any?
>>> puts dns.getaddress("google.com")
>>>   end
>>> end
>>> 
>>> To reference Mike's question. What I found was that 'if ress.any?' works 
>>> and that is what allows me to protect against malformed host names or a 
>>> failure to find an A record. 
>>> 
>>> So I've already chopped out the puppet stuff, and this code works. So I'm 
>>> thinking that it must be something with the require statement, where it 
>>> isn't finding the library I need. But I'm not sure what I can do from here. 
>>> 
>>> On Friday, October 3, 2014 2:00:27 AM UTC-4, Wil Cooley wrote:
>>> 
>>> On Oct 2, 2014 10:23 AM, "Mark Rosedale"  wrote:
>>> >
>>> > I have the following custom function that I'm trying to write. 
>>> >
>>> 
>>> Sorry this isn't an answer to your question, but I recently published a 
>>> module of functions wrapping the standard system get*by* functions (well, 
>>> wrapping Ruby's interfaces to the standard system functions):  
>>> https://forge.puppetlabs.com/wcooley/name_service_lookups
>>> 
>>> This includes `gethostbyname` and `gethostbyaddr`; the main benefit over 
>>> querying DNS directly is that it understands nsswitch, so /etc/hosts works 
>>> and any other host database you might want to use.
>>> 
>>> But assuming you want to implement this anyway an exercise in learning Ruby 
>>> & Puppet extensions, you might start by removing all the Puppet stuff and 
>>> just get the lookups working as a simple standalone Ruby script.
>>> 
>>> Wil
>>> 
>>> require 'resolv'
>>> >
>>> > module Puppet::Parser::Functions
>>> >   newfunction(:getIpAddr, :type => :rvalue) do |arguments|
>>> > Resolv::DNS.open do |dns|
>>> >   ress = dns.getresources(arguments[0], Resolv::DNS::Resource::IN::A)
>>> >   if ress.any?
>>> > dns.getaddress(arguments[0])
>>> > #break
>>> >