Re: [Puppet Users] Re: Clarification on mount type behaviour

2017-03-30 Thread Stefan Schulte

Hi

On 30.03.2017 14:57, jcbollinger wrote:


mounted.  But perhaps it doesn't have to be limited that way.  Expanding
its scope to cover the options with which the filesystem is actually
mounted seems like a reasonable feature request.  And if you don't want
to wait, then very likely you can roll your own by writing and using an
extension of the existing "parsed" provider that adds the behavior you want.


John


actually there is an ancient one

https://projects.puppetlabs.com/issues/6309

that finally ended in a forge module

https://forge.puppet.com/puppetlabs/mount_providers

The problem is that if you describe the desired value (e.g. options => 
"ro"), what is the current value? The value in /etc/fstab or in 
/proc/self/mounts?


The forge module solves this dilemma by introducing two separate types 
(that can be abstracted again to one define) but since the original 
intention was to merge this back into core and this never happened I am 
not sure of the general quality of this module. When it was first 
released (which is a while back now) it introduced issues that had been 
solved in the original mount provider and have been reintroduced in the 
module (e.g. https://projects.puppetlabs.com/issues/4914) so make sure 
the module is usable first.


- Stefan

--
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/a9c1f057-b005-4a03-e48e-8cf82bc8f7d3%40posteo.de.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] facters or Custom Facts

2017-03-30 Thread Rob Nelson
Warron,

Hiera is a lot easier than it seems! If you join the puppet slack (
https://slack.puppet.com), I'm sure we could help you get it set up quickly
and properly. It will probably solve a dozen other problems you didn't even
know you had, too :)


Rob Nelson
rnels...@gmail.com

On Thu, Mar 30, 2017 at 11:01 AM, warron.french 
wrote:

> Hi Rob, I am not quite (personally/professionally) ready for Hiera yet.  I
> also need to learn more about ERB templates; which I did a little research
> on about 2 hours ago.
>
> Honestly, what you provided above to me, because I am not ready/fully
> understanding yet, has no context for me to implement your idea.  Which, if
> I did, I would gracefully accept your input and get it done.  :-/
>
> Thanks for this suggestion.  I simply am not there yet.
>
> Sincerely, thank you.
>
> --
> Warron French
>
>
> On Thu, Mar 30, 2017 at 9:58 AM, Rob Nelson  wrote:
>
>> You could create a parameter called `$manage_audispatch = false` and in
>> hiera, set `profile::whatever::manage_audispatch: true` in hiera for
>> qualified devices (probably osfamily of RedHat, os/release/major of 6).
>> Your code conditional is very simple (`if $manage_audispatch { .. }`),
>> abstract out the complexity with hiera.
>>
>>
>> Rob Nelson
>> rnels...@gmail.com
>>
>> On Thu, Mar 30, 2017 at 7:43 AM, warron.french 
>> wrote:
>>
>>> I need to develop a conditional that will allow me to deploy audit.rules,
>>> auditd.conf, and *IF (and only if) the machine is a Server* audispatch
>>> configurations.
>>>
>>> The ausyscalls for RHEL6 are different from RHEL7, so I require the
>>> ability "deploy" audit.rules.el7 into the correct place, and
>>> audit.rules.el6 into the appropriate place for RHEL6 (they aren't the same
>>> place).
>>>
>>> I am working with Red Hat Enterprise Linux only; not any of the variants.
>>>
>>> So, I figured I would develop a CASE statement based on the following
>>> strings; hopefully derived from Puppet builtin facter facts:
>>>
>>> RHEL-6-Server
>>> RHEL-6-Client|RHEL-6-Desktop
>>> RHEL-7-Server
>>> RHEL-7-Client|RHEL-7-Desktop
>>>
>>> The problem is I cannot derive a string that looks like this in any
>>> order of the hyphenated parts, or without for that matter.
>>>
>>> I found 1 facter that has the parts I need, that might enable me to
>>> generate the string(s) I need; but I don't know how to tease out the values
>>> from the particular facter = *os*.
>>>
>>> The facter, *os*, offers something I can use (puppet-facter syntax not
>>> specifically used below):
>>>
>>>- os/release/major would give me a 6 or a 7;
>>>- os/distid
>>>
>>> Can someone help me generate these strings; even if looked like
>>> RHEL-Server-6, that would be something I could work with in my class.
>>>
>>> Oh!  Red Hat offers a file called */etc/system-release-cpe*; but they
>>> didn't bother to enforce consistency in either the values as formatted or
>>> the order in which certain data is arranged within the same variables.
>>>
>>>
>>> Thanks in advance,
>>>
>>> --
>>> Warron French
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "Puppet Users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send
>>> an email to puppet-users+unsubscr...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/ms
>>> gid/puppet-users/CAJdJdQ%3D-TEf_Dz0ec8vG8MwYpnr44SBCnVubhS%3
>>> DWBJ8N75TeqQ%40mail.gmail.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/ms
>> gid/puppet-users/CAC76iT_rQSaUfo5aiQgGnTJuset%2BxAR6POh%
>> 3DYg0SjCU3je3EEQ%40mail.gmail.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/CAJdJdQm3wALOCOJW9qLiq-SzHpn7WPdSd-huY4OZLPz8%
> 2BT9JsQ%40mail.gmail.com
> 
> .
> For more options, visit https://g

Re: [Puppet Users] Spec testing and dalen-puppetdbquery

2017-03-30 Thread Erik Dalén
A bit late to the party here, but in my (rspec-puppet) tests I have created
a mock version of the function in a before(:each) block in the unit test
for the class, like this:

  before(:each) do
Puppet::Parser::Functions.newfunction(:query_nodes, :type => :rvalue) {
|_| ["foo.example.com", "bar.example.com"] }
  end



On Mon, 19 Dec 2016 at 18:23 Jordan Conway  wrote:

> I was running into the same issue with that module, and I found that
> including the puppetdb mock class from the source module helped.
> It may be more involved, but at first glance, this helps me quiet a bunch
> of the errors to get down to spec testing my actual module.
>
>
> https://raw.githubusercontent.com/dalen/puppet-puppetdbquery/master/spec/puppet/util/puppetdb.rb
>
> Cheers,
> Jordan
>
>
> On Tuesday, November 1, 2016 at 6:13:03 PM UTC-4, Salty Old Cowdawg wrote:
>
> Garret:  I do have dalen-puppetdb in my .fixtures.yaml file.   A link to
> my project?  unfortunately I'm developing all this work inside my client's
> cloud and can't provide a link.
>
> On Tue, Nov 1, 2016 at 6:11 PM Peter Berghold  wrote:
>
> That's what I was beginning to suspect Andy.  Now I have to go find the
> Ubuntu version of that
>
> On Tue, Nov 1, 2016 at 5:38 PM Andrew Grimberg 
> wrote:
>
> On 11/01/2016 02:25 PM, Garrett Honeycutt wrote:
> > On 11/1/16 4:03 PM, Peter Berghold wrote:
> >> I have a module that I am writing spec tests for that uses the Puppet
> >> Forge module cited in the subject line to query for a list of nodes
> >> fitting a particular criteria.  When I run the spec test it bombs out
> >> with a message: "cannot load such file -- puppet/util/puppetdb"
> >>
> >> After a bit of searching I am still left wondering package or gem this
> >> is looking for.  Anybody know?
> >>
> >
> > Hi,
> >
> > Do you have dalen/puppet-puppetdbquery in your .fixtures.yml? A link to
> > your project would make debugging easier.
>
> It's probably related to the fact that dalen-puppetdbquery requires
> PuppetDB Terminus installed. Not certain how you get around that for
> spec tests.
>
> -Andy-
>
> --
> 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/ea142093-9c29-2fe2-8202-0ae09709ef21%40bardicgrove.org
> .
> 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/58d955c3-1c4d-4e37-b29b-d952f0e64775%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/CAAAzDLfhHUWsU5ScFFB_9KCzNBo49L2XyaRsvrC_Uw67gAKFmw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] removing "minimum_uid=1000" value from all my pam config files

2017-03-30 Thread Peter K
I'm trying to remove a specific configuration value, "minimum_uid=1000", 
from multiple lines in several files (currently 5 files) in /etc/pam.d/.
A typical line looks like this:
auth [success=1 default=ignore]  pam_ldap.so use_first_pass 
minimum_uid=1000

I've tried exec and sed, but I couldn't figure out the necessary escaping 
to get the filename variable to parse (here I test with 'abc'):
define removeMinimumUID(){
exec { '${filename}':
  command => "/usr/bin/sed -i \'s|abc|cab|g\' ${filename}",
  onlyif => '/usr/bin/test -e ${filename}',
  refresh => '/usr/bin/true',
  provider => 'posix',
  logoutput => on_failure,
}
}

RemoveMinimumUID { "/mnt/NY_Interactive/dev/peter/puppet/abc.txt": }

Error:
Executing: '/usr/bin/sed -i 's|abc|cab|g' '^[[0m
^[[mNotice: 
/Stage[main]/Main/Removeminimumuid[/mnt/NY_Interactive/dev/peter/puppet/abc.txt]/Exec[${filename}]/returns:
 
/usr/bin/sed: no input files^[[0m

If I substitute the fully qualified filename with the filename variable on 
the 'commmand' parameter line, the script runs fine.



Then I tried stdlibs' file_line but I couldn't figure out how to replace a 
substring without identifying the entire replacement string:


file { '/home/peter/dev/puppet/abc.txt':
  ensure => present,
}->
file_line { 'Append a line to /home/peter/dev/puppet/abc.txt':
  path => '/home/peter/dev/puppet/abc.txt',
  line => 'cab',
  multiple => true,
  match   => "abc$",
}


I'm currently looking at augeas but no luck yet.

Suggestions?
thx...


-- 
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/9f8076c3-fa00-4b8d-84c1-dfdee90b4929%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] how to pxe boot and preseed puppet-agent install in ubuntu from puppetlabs repo

2017-03-30 Thread Peter K
Thanks for the suggestion, Tom.
I was working with a pre-existing environment but setting up cobbler is 
something I'll try next.
-peter

On Thursday, March 23, 2017 at 5:08:42 PM UTC-4, duke wrote:
>
> Hi Peter, 
>
> ever thought about trying Cobbler? 
>
> In our environment, we PXE boot servers with Cobbler, install Xenial 
> with a recent Puppet agent and automatically sign the certificate on 
> the master for freshly deployed servers. Everything out of the box :) 
>
> Hth, 
> Tom. 
>
> On Wed, 2017-03-22 at 13:06 -0700, Peter K wrote: 
> > In my googling I did not find a simple recipe for how to install and 
> > run puppet for the first time (for a pxe / tftpboot / ubuntu / 
> > preseed / puppetlabs-repo scenario). 
> > 
> > Here's what I tagged onto the bottom on my preseed.cfg script: 
> > 
> > d-i preseed/late_command string in-target wget -O 
> > /home//puppetlabs-release-pc1-xenial.deb http://apt.puppetl 
> > abs.com/puppetlabs-release-pc1-xenial.deb;\ 
> > in-target /usr/bin/dpkg -i /home//puppetlabs- 
> > release-pc1-xenial.deb;\ 
> > in-target /usr/bin/apt-get update;\ 
> > in-target /usr/bin/apt-get install -y --allow-unauthenticated 
> > puppet-agent; 
> > #in-target /opt/puppetlabs/puppet/bin/puppet resource service 
> > puppet ensure=running enable=true; # this line wan't necessary 
> > because puppet joined the server and ran for the first time on first 
> > boot with no other configuration...if you have autosigning set up. 
> > 
> > # This script assumes you have autosigning turned on by putting a 
> > single asterisk in this file on the puppet server: 
> > /etc/puppetlabs/puppet/autosign.conf 
> > 
> > Here's my pxelinux.cfg/default snipit (how the preseed.cfg is 
> > called): 
> > 
> >  LABEL ubuntu-16.04.2 server LTS with preseed 
> >  MENU LABEL ubuntu-16.04.2 server LTS with preseed 
> >  KERNEL images/ubuntu-16.04.2-server-amd64.iso/linux 
> >  APPEND initrd=images/ubuntu-16.04.2-server-amd64.iso/initrd.gz 
> > inst.repo=ftp:///pub/ubuntu-16.04.2-server-amd64.iso 
> > auto=true priority=critical debian-installer/locale=en_US keyboard- 
> > configuration/layoutcode=us ubiquity/reboot=true 
> > languagechooser/language-name=English countrychooser/shortlist=US 
> > localechooser/supported-locales=en_US.UTF-8 boot=casper automatic- 
> > ubiquity quiet splash noprompt noshell preseed/url=ftp:// > address>/pub/kickstarter/preseed.cfg --- 
> > 
> > # and ftp:///pub/ubuntu-16.04.2-server-amd64.iso is a 
> > mountpoint to the file of the same name. 
> > # Make sure and change the  and  fields with 
> > your own. 
> > --  
> > 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/7a874867-5ed5-4928-890d- 
> > e9dbaec15b31%40googlegroups.com. 
> > For more options, visit https://groups.google.com/d/optout. 
> -- 
> Thomas "Duke" Hager   du...@sigsegv.at 
>  
> GPG: 2048R/791C5EB1http://www.sigsegv.at/gpg/duke.gpg 
> = 
> "Never Underestimate the Power of Stupid People in Large Groups."

-- 
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/ee6ac4b7-cdb9-431f-8ed1-13311c318454%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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 fact uses the =~ operator to do pattern matching on an 
array of strings.

Facter.add(:screen_count) do
confine :kernel => 'Linux'
setcode do
@screens = Facter::Core::Execution.exec("/usr/bin/xrandr -display 
:0").split("\n")
@screens.count { |x| x =~ /connected/ }
end
end

IMO piping grep to awk is never necessary.  awk has a built-in search 
function, just use it!  The command used in that fact could be rewritten as 
follows.

 ethtool_g = %x{ethtool -g #{int} 2>/dev/null  | awk '/^(RX|TX)/ {print 
$2}'}

Still messy and a more native way to do it would be like this.

%x{ethtool -g #{int} 2>/dev/null}.each_line do |line|
puts line.split("\s")[-1] if line =~ /^(RX|TX):/
end


On Thursday, March 30, 2017 at 11:11:35 AM UTC-4, 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 to 
> suggest?
>
> Secondly, the link= 
> https://github.com/LMAX-Exchange/puppet-networking-example/blob/master/lib/facter/interface_ringbuffer.rb
>  
> did have a reference to awk; thank you.
> However, the syntax:
>   ethtool_g = %x{/sbin/ethtool -g #{int} 2>/dev/null | grep -P 
> '^(RX|TX):' | awk '{print $2}'}
>
> Looks like something other than just plain shell scripting, so can you 
> break this down for me just a little bit?
>
> I recognize what looks like a variable, called ethtool_g, and then it 
> continues with assignement based on %x{...}  where the "" is your 
> shell scripting.
>
> What is the *%x* a reference for/to?  Can I simply replace your variable 
> with one of my own, and your shell scripting between the curly braces with 
> my own shell scripting?
>
> Is that legal, and is this in the language of ruby (so I have a reference 
> point of where to go to look up more examples?
>
> Sorry for the load of questions.  Thank you for the information.
>
> --
> Warron French
>
>
> On Thu, Mar 30, 2017 at 11:03 AM, warron.french  > wrote:
>
>> 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/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/interface_ringbuffer.rb
>>>
>>> -Luke
>>>
>>> On Thursday, 30 March 2017 13:10:35 UTC+1, Warron French wrote:

 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 Schaeffer <
 jschaef...@gmail.com> 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 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 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 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 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, 
>>> or will Puppet simply execute the shell script with:
>>>
>>> sh scriptname.sh
>>>
>>> Thanks for the feedback,
>>>
>>> --
>>> 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 

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 to 
> suggest?
>
>
Oh, I wasn't giving you Awk examples specifically, I was giving you one 
with a small amount of Ruby, and one with a bit more Ruby and some string 
manipulation in it. The use of Awk and piped shell commands in my Fact 
there is 100% pure laziness, it would be more "robust" to do all of the 
string manipulation in Ruby.
 

> Secondly, the link= 
> https://github.com/LMAX-Exchange/puppet-networking-example/blob/master/lib/facter/interface_ringbuffer.rb
>  
> did have a reference to awk; thank you.
> However, the syntax:
>   ethtool_g = %x{/sbin/ethtool -g #{int} 2>/dev/null | grep -P 
> '^(RX|TX):' | awk '{print $2}'}
>
> Looks like something other than just plain shell scripting, so can you 
> break this down for me just a little bit?
>
> I recognize what looks like a variable, called ethtool_g, and then it 
> continues with assignement based on %x{...}  where the "" is your 
> shell scripting.
>
> What is the *%x* a reference for/to?  Can I simply replace your variable 
> with one of my own, and your shell scripting between the curly braces with 
> my own shell scripting?
>
 
Correct, ethtool_g is a Ruby variable.

%x{} is one of the ways of executing something in a Shell and getting it's 
STDOUT, there are other ways, this post explains it well: 
 http://stackoverflow.com/questions/2232/calling-shell-commands-from-ruby

the #{int} is embedding a Ruby variable called 'int' defined earlier into 
the string.

Is that legal, and is this in the language of ruby (so I have a reference 
> point of where to go to look up more examples?
>

Yes, you can.

What I would recommend is copy one of those Facts to your homedir, then set 
an environment variable FACTERLIB=/home/$USERNAME, which sets an extra 
Facter search path to your homedir. If you then run "facter -p" you should 
see the new Fact in the list. Then you can edit your Fact to your heart's 
content, and Google every crash or error message you come up with ;-) Once 
it actually works you can add the Fact to a module and distribute it to 
servers.

-Luke
 

> Sorry for the load of questions.  Thank you for the information.
>
> --
> Warron French
>
>
> On Thu, Mar 30, 2017 at 11:03 AM, warron.french  > wrote:
>
>> 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/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/interface_ringbuffer.rb
>>>
>>> -Luke
>>>
>>> On Thursday, 30 March 2017 13:10:35 UTC+1, Warron French wrote:

 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 Schaeffer <
 jschaef...@gmail.com> 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 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 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 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 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, 
>>> or will Puppet simply execute the shell script with:
>>>
>>> sh scriptname.sh
>>>
>>> Thanks for the feedback,
>>>
>>> --
>>> Warron French
>>>
>>>
>>> On Wed, Mar 22, 2017 at 7:07 PM, Peter Bukowi

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-networking-example/blob/master/lib/facter/interface_ringbuffer.rb
did have a reference to awk; thank you.
However, the syntax:
  ethtool_g = %x{/sbin/ethtool -g #{int} 2>/dev/null | grep -P
'^(RX|TX):' | awk '{print $2}'}

Looks like something other than just plain shell scripting, so can you
break this down for me just a little bit?

I recognize what looks like a variable, called ethtool_g, and then it
continues with assignement based on %x{...}  where the "" is your
shell scripting.

What is the *%x* a reference for/to?  Can I simply replace your variable
with one of my own, and your shell scripting between the curly braces with
my own shell scripting?

Is that legal, and is this in the language of ruby (so I have a reference
point of where to go to look up more examples?

Sorry for the load of questions.  Thank you for the information.

--
Warron French


On Thu, Mar 30, 2017 at 11:03 AM, warron.french 
wrote:

> 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/
>> 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/interface_ringbuffer.rb
>>
>> -Luke
>>
>> On Thursday, 30 March 2017 13:10:35 UTC+1, Warron French wrote:
>>>
>>> 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 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 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 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 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 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,
>> or will Puppet simply execute the shell script with:
>>
>> sh scriptname.sh
>>
>> Thanks for the feedback,
>>
>> --
>> 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/custom_facts.html#executa
>>> ble-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 will be synced to all your nodes (assuming you use
>>> pluginsync).
>>>
>>> The only requirement for executable fact scripts is that they must
>>> return key/value pairs in the format 'key=value'. Multiple
>>> keys/values
>>> get their own line. In your case, you could do something like this:
>>>
>>> -
>>> #!/bin/bash
>>>
>>> key="qty_monitors_total"
>>> value=$(your parsing command for /var/log/Xorg.0.log here)
>>>
>>> echo "${key}=${value}"
>>> -
>>>
>>> Save the file as an executable script in the above mentioned path and
>>> it should be available on the next puppet run.
>>>
>>> On Wed, Mar 22, 2017 at 3:24 PM, warron.french 
>>> wrote:
>>> > 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

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/
> 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/interface_ringbuffer.rb
>
> -Luke
>
> On Thursday, 30 March 2017 13:10:35 UTC+1, Warron French wrote:
>>
>> 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 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 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 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 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 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, or
> will Puppet simply execute the shell script with:
>
> sh scriptname.sh
>
> Thanks for the feedback,
>
> --
> 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/custom_facts.html#executa
>> ble-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 will be synced to all your nodes (assuming you use pluginsync).
>>
>> The only requirement for executable fact scripts is that they must
>> return key/value pairs in the format 'key=value'. Multiple keys/values
>> get their own line. In your case, you could do something like this:
>>
>> -
>> #!/bin/bash
>>
>> key="qty_monitors_total"
>> value=$(your parsing command for /var/log/Xorg.0.log here)
>>
>> echo "${key}=${value}"
>> -
>>
>> Save the file as an executable script in the above mentioned path and
>> it should be available on the next puppet run.
>>
>> On Wed, Mar 22, 2017 at 3:24 PM, warron.french 
>> wrote:
>> > 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"
>> > /var/log/Xorg.0.log | cut -d\) -f2,3,4 | grep GPU |sort -u | wc -l')
>> >   end
>> > end
>> >
>> > I don't know of any other way to do this yet; but that's not my
>> concern yet.
>> >
>> > What I would like to know is how can I use an awk command within the
>> > Facter::Util::Resolution.exec('.') line.
>> >
>> > I have a need to essentially reproduce the line above but drop   wc
>> -l and
>> > add awk '{ print $2"_"$3"_on_"$1$4 }'
>> >
>> > I need the awk command to pretty much look like this; the problem
>> is awk
>> > uses its own single quotes (') and it will break the ruby code.
>> >
>> > I am not a ruby developer; so if someone could either tell me:
>> >
>> > It's just not possible; or
>> > do it this way
>> >
>> >
>> > That would be greatly appreciated.  Thank you,
>> >
>> > --
>> > Warron French
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups
>> > "Puppet Users" group.
>> > To unsubscribe from this group and stop receiving emails from it,
>> send an
>> > email to puppet-users...@googlegroups.com.
>> > To view this discussion on 

Re: [Puppet Users] facters or Custom Facts

2017-03-30 Thread warron.french
Hi Rob, I am not quite (personally/professionally) ready for Hiera yet.  I
also need to learn more about ERB templates; which I did a little research
on about 2 hours ago.

Honestly, what you provided above to me, because I am not ready/fully
understanding yet, has no context for me to implement your idea.  Which, if
I did, I would gracefully accept your input and get it done.  :-/

Thanks for this suggestion.  I simply am not there yet.

Sincerely, thank you.

--
Warron French


On Thu, Mar 30, 2017 at 9:58 AM, Rob Nelson  wrote:

> You could create a parameter called `$manage_audispatch = false` and in
> hiera, set `profile::whatever::manage_audispatch: true` in hiera for
> qualified devices (probably osfamily of RedHat, os/release/major of 6).
> Your code conditional is very simple (`if $manage_audispatch { .. }`),
> abstract out the complexity with hiera.
>
>
> Rob Nelson
> rnels...@gmail.com
>
> On Thu, Mar 30, 2017 at 7:43 AM, warron.french 
> wrote:
>
>> I need to develop a conditional that will allow me to deploy audit.rules,
>> auditd.conf, and *IF (and only if) the machine is a Server* audispatch
>> configurations.
>>
>> The ausyscalls for RHEL6 are different from RHEL7, so I require the
>> ability "deploy" audit.rules.el7 into the correct place, and
>> audit.rules.el6 into the appropriate place for RHEL6 (they aren't the same
>> place).
>>
>> I am working with Red Hat Enterprise Linux only; not any of the variants.
>>
>> So, I figured I would develop a CASE statement based on the following
>> strings; hopefully derived from Puppet builtin facter facts:
>>
>> RHEL-6-Server
>> RHEL-6-Client|RHEL-6-Desktop
>> RHEL-7-Server
>> RHEL-7-Client|RHEL-7-Desktop
>>
>> The problem is I cannot derive a string that looks like this in any order
>> of the hyphenated parts, or without for that matter.
>>
>> I found 1 facter that has the parts I need, that might enable me to
>> generate the string(s) I need; but I don't know how to tease out the values
>> from the particular facter = *os*.
>>
>> The facter, *os*, offers something I can use (puppet-facter syntax not
>> specifically used below):
>>
>>- os/release/major would give me a 6 or a 7;
>>- os/distid
>>
>> Can someone help me generate these strings; even if looked like
>> RHEL-Server-6, that would be something I could work with in my class.
>>
>> Oh!  Red Hat offers a file called */etc/system-release-cpe*; but they
>> didn't bother to enforce consistency in either the values as formatted or
>> the order in which certain data is arranged within the same variables.
>>
>>
>> Thanks in advance,
>>
>> --
>> Warron French
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Puppet Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to puppet-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit https://groups.google.com/d/ms
>> gid/puppet-users/CAJdJdQ%3D-TEf_Dz0ec8vG8MwYpnr44SBCnVubhS%3
>> DWBJ8N75TeqQ%40mail.gmail.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/CAC76iT_rQSaUfo5aiQgGnTJuset%
> 2BxAR6POh%3DYg0SjCU3je3EEQ%40mail.gmail.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/CAJdJdQm3wALOCOJW9qLiq-SzHpn7WPdSd-huY4OZLPz8%2BT9JsQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [Puppet Users] facters or Custom Facts

2017-03-30 Thread Rob Nelson
You could create a parameter called `$manage_audispatch = false` and in
hiera, set `profile::whatever::manage_audispatch: true` in hiera for
qualified devices (probably osfamily of RedHat, os/release/major of 6).
Your code conditional is very simple (`if $manage_audispatch { .. }`),
abstract out the complexity with hiera.


Rob Nelson
rnels...@gmail.com

On Thu, Mar 30, 2017 at 7:43 AM, warron.french 
wrote:

> I need to develop a conditional that will allow me to deploy audit.rules,
> auditd.conf, and *IF (and only if) the machine is a Server* audispatch
> configurations.
>
> The ausyscalls for RHEL6 are different from RHEL7, so I require the
> ability "deploy" audit.rules.el7 into the correct place, and
> audit.rules.el6 into the appropriate place for RHEL6 (they aren't the same
> place).
>
> I am working with Red Hat Enterprise Linux only; not any of the variants.
>
> So, I figured I would develop a CASE statement based on the following
> strings; hopefully derived from Puppet builtin facter facts:
>
> RHEL-6-Server
> RHEL-6-Client|RHEL-6-Desktop
> RHEL-7-Server
> RHEL-7-Client|RHEL-7-Desktop
>
> The problem is I cannot derive a string that looks like this in any order
> of the hyphenated parts, or without for that matter.
>
> I found 1 facter that has the parts I need, that might enable me to
> generate the string(s) I need; but I don't know how to tease out the values
> from the particular facter = *os*.
>
> The facter, *os*, offers something I can use (puppet-facter syntax not
> specifically used below):
>
>- os/release/major would give me a 6 or a 7;
>- os/distid
>
> Can someone help me generate these strings; even if looked like
> RHEL-Server-6, that would be something I could work with in my class.
>
> Oh!  Red Hat offers a file called */etc/system-release-cpe*; but they
> didn't bother to enforce consistency in either the values as formatted or
> the order in which certain data is arranged within the same variables.
>
>
> Thanks in advance,
>
> --
> Warron French
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to puppet-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-users/CAJdJdQ%3D-TEf_Dz0ec8vG8MwYpnr44SBCnVubhS%
> 3DWBJ8N75TeqQ%40mail.gmail.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/CAC76iT_rQSaUfo5aiQgGnTJuset%2BxAR6POh%3DYg0SjCU3je3EEQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Re: Clarification on mount type behaviour

2017-03-30 Thread jcbollinger


On Wednesday, March 29, 2017 at 6:36:01 AM UTC-5, apgrif...@gmail.com wrote:
>
> Hi,
>
> From my testing it seems that when managing mount resources puppet only 
> compares the manifest against fstab and not mtab. For example if I have
>
> mount { '/tmp':
>   ensure  => mounted,
>   options => 'noexec,nodev,nosuid',
> }
>
> And then do mount -o remount,exec /tmp
>
> I would expect the next puppet run to correct this, but I'm not seeing 
> this, only if I edit fstab is the resource updated. Is this expected 
> behavior?
>
>
It is the longtime behavior associated with the "parsed" provider for the 
Mount resource type (the only provider for that type included in the box).  
The documentation does not explicitly say that mtab is ignored, but if you 
read carefully then you will find that the behavior is characterized in 
some places in terms of the "filesystem table" and in at least one place 
explicitly in terms of fstab.  Look in particular at the documentation for 
Mount.ensure 
.

Overall, then, the Mount resource type primarily manages entries in fstab, 
and only secondarily manages whether the designated filesystem is mounted.  
But perhaps it doesn't have to be limited that way.  Expanding its scope to 
cover the options with which the filesystem is actually mounted seems like 
a reasonable feature request.  And if you don't want to wait, then very 
likely you can roll your own by writing and using an extension of the 
existing "parsed" provider that adds the behavior you want.


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/3be04523-0565-4ed8-9fe8-54e2bb8f812f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


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/interface_ringbuffer.rb

-Luke

On Thursday, 30 March 2017 13:10:35 UTC+1, Warron French wrote:
>
> 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 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 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 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 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 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, or 
 will Puppet simply execute the shell script with:

 sh scriptname.sh

 Thanks for the feedback,

 --
 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/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 will be synced to all your nodes (assuming you use pluginsync).
>
> The only requirement for executable fact scripts is that they must
> return key/value pairs in the format 'key=value'. Multiple keys/values
> get their own line. In your case, you could do something like this:
>
> -
> #!/bin/bash
>
> key="qty_monitors_total"
> value=$(your parsing command for /var/log/Xorg.0.log here)
>
> echo "${key}=${value}"
> -
>
> Save the file as an executable script in the above mentioned path and
> it should be available on the next puppet run.
>
> On Wed, Mar 22, 2017 at 3:24 PM, warron.french  
> wrote:
> > 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"
> > /var/log/Xorg.0.log | cut -d\) -f2,3,4 | grep GPU |sort -u | wc -l')
> >   end
> > end
> >
> > I don't know of any other way to do this yet; but that's not my 
> concern yet.
> >
> > What I would like to know is how can I use an awk command within the
> > Facter::Util::Resolution.exec('.') line.
> >
> > I have a need to essentially reproduce the line above but drop   wc 
> -l and
> > add awk '{ print $2"_"$3"_on_"$1$4 }'
> >
> > I need the awk command to pretty much look like this; the problem is 
> awk
> > uses its own single quotes (') and it will break the ruby code.
> >
> > I am not a ruby developer; so if someone could either tell me:
> >
> > It's just not possible; or
> > do it this way
> >
> >
> > That would be greatly appreciated.  Thank you,
> >
> > --
> > Warron French
> >
> > --
> > You received this message because you are subscribed to the Google 
> Groups
> > "Puppet Users" group.
> > To unsubscribe from this group and stop receiving emails from it, 
> send an
> > email to puppet-users...@googlegroups.com.
> > To view this discussion on the web visit
> > 
> https://groups.google.com/d/msgid/puppet-users/CAJdJdQmZXQAd%2Bo%2Bnp-NHqxGHnXubf%2Bac-dP5FPoy4QYMEVuBuA%40mail.gmail.com
> .
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to 

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 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 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 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 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 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, or will
>>> Puppet simply execute the shell script with:
>>>
>>> sh scriptname.sh
>>>
>>> Thanks for the feedback,
>>>
>>> --
>>> 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/custom_facts.html#executa
 ble-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 will be synced to all your nodes (assuming you use pluginsync).

 The only requirement for executable fact scripts is that they must
 return key/value pairs in the format 'key=value'. Multiple keys/values
 get their own line. In your case, you could do something like this:

 -
 #!/bin/bash

 key="qty_monitors_total"
 value=$(your parsing command for /var/log/Xorg.0.log here)

 echo "${key}=${value}"
 -

 Save the file as an executable script in the above mentioned path and
 it should be available on the next puppet run.

 On Wed, Mar 22, 2017 at 3:24 PM, warron.french 
 wrote:
 > 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"
 > /var/log/Xorg.0.log | cut -d\) -f2,3,4 | grep GPU |sort -u | wc -l')
 >   end
 > end
 >
 > I don't know of any other way to do this yet; but that's not my
 concern yet.
 >
 > What I would like to know is how can I use an awk command within the
 > Facter::Util::Resolution.exec('.') line.
 >
 > I have a need to essentially reproduce the line above but drop   wc
 -l and
 > add awk '{ print $2"_"$3"_on_"$1$4 }'
 >
 > I need the awk command to pretty much look like this; the problem is
 awk
 > uses its own single quotes (') and it will break the ruby code.
 >
 > I am not a ruby developer; so if someone could either tell me:
 >
 > It's just not possible; or
 > do it this way
 >
 >
 > That would be greatly appreciated.  Thank you,
 >
 > --
 > Warron French
 >
 > --
 > You received this message because you are subscribed to the Google
 Groups
 > "Puppet Users" group.
 > To unsubscribe from this group and stop receiving emails from it,
 send an
 > email to puppet-users...@googlegroups.com.
 > To view this discussion on the web visit
 > https://groups.google.com/d/msgid/puppet-users/CAJdJdQmZXQAd
 %2Bo%2Bnp-NHqxGHnXubf%2Bac-dP5FPoy4QYMEVuBuA%40mail.gmail.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/ms
 gid/puppet-users/CAJA1CN9aFH4Eza-FoxzrfXDWiGCUHXE%2BGFt2Nu%3
 DjK2eDzV4upg%40mail.gmail.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 gr

[Puppet Users] Re: Augeas-1.5.0 to edit file using Puppet

2017-03-30 Thread Peter Faller
Is there any reason you're not using the built-in 'host' type? For example, 
this adds an entry to /etc/hosts:

  host {'north.xyz.com':
ip => '192.168.100.2',
host_aliases => [
  'north', 'main-switch'
],
  }


On Thursday, 30 March 2017 09:55:33 UTC+2, Shrawan Bhagwat wrote:
>
>
>

-- 
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/8732bc95-9364-4062-b4b1-c0ac92d021a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] facters or Custom Facts

2017-03-30 Thread warron.french
I need to develop a conditional that will allow me to deploy audit.rules,
auditd.conf, and *IF (and only if) the machine is a Server* audispatch
configurations.

The ausyscalls for RHEL6 are different from RHEL7, so I require the ability
"deploy" audit.rules.el7 into the correct place, and audit.rules.el6 into
the appropriate place for RHEL6 (they aren't the same place).

I am working with Red Hat Enterprise Linux only; not any of the variants.

So, I figured I would develop a CASE statement based on the following
strings; hopefully derived from Puppet builtin facter facts:

RHEL-6-Server
RHEL-6-Client|RHEL-6-Desktop
RHEL-7-Server
RHEL-7-Client|RHEL-7-Desktop

The problem is I cannot derive a string that looks like this in any order
of the hyphenated parts, or without for that matter.

I found 1 facter that has the parts I need, that might enable me to
generate the string(s) I need; but I don't know how to tease out the values
from the particular facter = *os*.

The facter, *os*, offers something I can use (puppet-facter syntax not
specifically used below):

   - os/release/major would give me a 6 or a 7;
   - os/distid

Can someone help me generate these strings; even if looked like
RHEL-Server-6, that would be something I could work with in my class.

Oh!  Red Hat offers a file called */etc/system-release-cpe*; but they
didn't bother to enforce consistency in either the values as formatted or
the order in which certain data is arranged within the same variables.


Thanks in advance,

--
Warron French

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/CAJdJdQ%3D-TEf_Dz0ec8vG8MwYpnr44SBCnVubhS%3DWBJ8N75TeqQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[Puppet Users] Augeas-1.5.0 to edit file using Puppet

2017-03-30 Thread Shrawan Bhagwat
Hi All,

I have configured Puppet 3.8.1 and Augeas 1.5.0.

I am trying to edit /etc/hosts file using augeas with following code:

augeas{'host_file':
context => "/files/etc/hosts",
changes => [
  "set ipaddr 192.168.0.1",
  "set canonical pigiron.example.com",
  "set alias[1] pigiron",
  "set alias[2] piggy",
],
}

When i am applying this config on Node, it's giving following error:
Error: /Stage[main]/Aug_mod::Configuration_files/Augeas[host_file]: Could 
not evaluate: undefined method `set' for #

Please guide.


-- 
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/76dbf3da-c912-465b-981b-d19cda59df6f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.