Re: [Puppet Users] Custom Facts using awk

2017-04-03 Thread warron.french
Wow is that a lot to take in. I simply need to learn Ruby to cut down on noise, or so it seems. Thanks Michael. -- Warron French On Thu, Mar 30, 2017 at 12:23 PM, Michael Watters wrote: > %x is a ruby method which captures command output. IMO you can do most of > wha

Re: [Puppet Users] Custom Facts using awk

2017-03-30 Thread Michael Watters
%x is a ruby method which captures command output. IMO you can do most of what you need using native ruby methods, there's no need to pipe output to grep/sed/awk since ruby has built in pattern matching functions and if you're using ruby you might as well do it the ruby way. For example, this

Re: [Puppet Users] Custom Facts using awk

2017-03-30 Thread Luke Bigum
On Thursday, 30 March 2017 16:11:35 UTC+1, Warron French wrote: > > Hi Luke, I have some questions for you. > > First, the link= > https://github.com/puppetlabs/puppetlabs-apache/blob/master/lib/facter/apache_version.rb > > didn't have any reference to awk at all, was this the file you intended

Re: [Puppet Users] Custom Facts using awk

2017-03-30 Thread warron.french
Hi Luke, I have some questions for you. First, the link= https://github.com/puppetlabs/puppetlabs-apache/blob/master/lib/facter/apache_version.rb didn't have any reference to awk at all, was this the file you intended to suggest? Secondly, the link= https://github.com/LMAX-Exchange/puppet-network

Re: [Puppet Users] Custom Facts using awk

2017-03-30 Thread warron.french
Hey, thanks for the examples Luke! I am looking at them now. -- Warron French On Thu, Mar 30, 2017 at 8:31 AM, Luke Bigum wrote: > Puppet modules on Github are a good source. I've found a simple one: > > https://github.com/puppetlabs/puppetlabs-apache/blob/master/ > li

Re: [Puppet Users] Custom Facts using awk

2017-03-30 Thread Luke Bigum
Puppet modules on Github are a good source. I've found a simple one: https://github.com/puppetlabs/puppetlabs-apache/blob/master/lib/facter/apache_version.rb And one of my own that's a little more complicated: https://github.com/LMAX-Exchange/puppet-networking-example/blob/master/lib/facter/inte

Re: [Puppet Users] Custom Facts using awk

2017-03-30 Thread warron.french
Joshua, thanks for this feedback. I don't really know ruby; can you offer some ideas of where I can find other Puppet Facts written in Ruby that don't look like my originally posted example? Thank you sir. -- Warron French On Tue, Mar 28, 2017 at 10:51 AM, Joshua Schaef

Re: [Puppet Users] Custom Facts using awk

2017-03-29 Thread Joshua Schaeffer
Excellent. Good to know. I was told otherwise. Thanks, Joshua Schaeffer On Wednesday, March 29, 2017 at 7:11:55 AM UTC-6, Gabriel Schuyler wrote: > > Never fear, external facts work just fine in Puppet 3. > > On Tuesday, March 28, 2017 at 10:51:52 AM UTC-4, Joshua Schaeffer wrote: >> >> External

Re: [Puppet Users] Custom Facts using awk

2017-03-29 Thread Gabriel Schuyler
Never fear, external facts work just fine in Puppet 3. On Tuesday, March 28, 2017 at 10:51:52 AM UTC-4, Joshua Schaeffer wrote: > > External facts are a Puppet v4 feature only. You have to use Ruby to > create custom facts in Puppet v3. > > On Monday, March 27, 2017 at 3:54:00 PM UTC-6, Warron Fr

Re: [Puppet Users] Custom Facts using awk

2017-03-28 Thread Joshua Schaeffer
External facts are a Puppet v4 feature only. You have to use Ruby to create custom facts in Puppet v3. On Monday, March 27, 2017 at 3:54:00 PM UTC-6, Warron French wrote: > > OK, done, and done. But it still isn't showing up. > > Is this potentially because I am using PE-3.8 as a component of Re

Re: [Puppet Users] Custom Facts using awk

2017-03-27 Thread warron.french
OK, done, and done. But it still isn't showing up. Is this potentially because I am using PE-3.8 as a component of Red Hat Satellite? -- Warron French On Mon, Mar 27, 2017 at 5:28 PM, Peter Bukowinski wrote: > Hi Warron, > > Puppet executes the script directly, so you

Re: [Puppet Users] Custom Facts using awk

2017-03-27 Thread Peter Bukowinski
Hi Warron, Puppet executes the script directly, so you need the shebang line and you must ensure the file is executable. -- Peter > On Mar 27, 2017, at 2:25 PM, warron.french wrote: > > Peter, perhaps I misunderstood you; but, I thought I was supposed to be able > to use bash or sh scripting

Re: [Puppet Users] Custom Facts using awk

2017-03-27 Thread warron.french
Peter, perhaps I misunderstood you; but, I thought I was supposed to be able to use bash or sh scripting to generate facters of my own without the use of Ruby. The link you provided refers to a python script example. It also adds a shebang line at the top of the script; do I need the shebang line

Re: [Puppet Users] Custom Facts using awk

2017-03-24 Thread Joshua Schaeffer
Sorry, I may have been ambiguous with the file extensions. A text file should end in .txt. This means you define external facts like this: # This is a plain text file that defines two external facts my_fact1=my_value1 my_fact2=my_value2 An executable program or script should end in whatever ext

Re: [Puppet Users] Custom Facts using awk

2017-03-24 Thread Joshua Schaeffer
Yes, you can put multiple key=value pairs in a single file. Puppet v4 supports three known types: 1. YAML (must end in .yaml) 2. JSON (must end in .json) 3. Text (must end in .txt) When working with .txt files you can only define string values. Arrays and hashes are not supported. Als

Re: [Puppet Users] Custom Facts using awk

2017-03-23 Thread Branan Riley
On Wed, Mar 22, 2017 at 4:07 PM Peter Bukowinski wrote: > Hi Warron, > > I'd consider using an external, executable fact to avoid ruby altogether. > > > https://docs.puppet.com/facter/3.6/custom_facts.html#executable-facts-unix > > Basically, you can write a bash script (or use any language y

Re: [Puppet Users] Custom Facts using awk

2017-03-22 Thread warron.french
Thanks Rob. I will try both approaches; for me there is more appeal in simply using a shell script. Peter, can I generate multiple key=value pairs inside the same shell script? I don't explicitly have to do it the way you presented with key="key_name" value="evaluated_expression" echo "${key}=

Re: [Puppet Users] Custom Facts using awk

2017-03-22 Thread warron.french
Oh wow! That cool! Thanks for the different method Peter! -- Warron French On Wed, Mar 22, 2017 at 7:07 PM, Peter Bukowinski wrote: > Hi Warron, > > I'd consider using an external, executable fact to avoid ruby altogether. > > https://docs.puppet.com/facter/3.6/cust

Re: [Puppet Users] Custom Facts using awk

2017-03-22 Thread Rob Nelson
That's probably one of the best ways to do this. But... You CAN use double quotes around a string. You will need to escape characters that will otherwise be interpolated like double quotes and dollar signs. I'm going off memory but I think `"awk '{print \$1_\$2}'"` should interpolate to `awk '{pri

Re: [Puppet Users] Custom Facts using awk

2017-03-22 Thread Peter Bukowinski
Hi Warron, I'd consider using an external, executable fact to avoid ruby altogether. https://docs.puppet.com/facter/3.6/custom_facts.html#executable-facts-unix Basically, you can write a bash script (or use any language you want), drop it into '//facts.d/' on your puppet server, and it wil

[Puppet Users] Custom Facts using awk

2017-03-22 Thread warron.french
Hello, I have finally learned how to write a Custom Fact; and duplicated the syntax several times over inside the same .rb file. I am using syntax that looks like the following: Facter.add('qty_monitors_total') do setcode do Facter::Util::Resolution.exec('/bin/grep " connected