define line($file, $line, $ensure = 'present') {
case $ensure {
default : { err ( "unknown ensure value ${ensure}" ) }
present: {
exec { "/bin/echo '${line}' >> '${file}'":
unless => "/bin/grep -qFx '${line}' '${file}'"
}
}
absent: {
exec { "/usr/bin/perl -ni -e 'print unless /^\\Q${line}\\E\$/' '${file}'":
onlyif => "/bin/grep -qFx '${line}' '${file}'"
}
}
}
}
Called as:Hello all,
I am fairly new to Puppet but learning.
I know what I want to do can be done I just can not get things to go right...
We want to start using the capability of sudo to look in /etc/sudoers.d to get user specific sudo permissions. Before we add a User_Alias file, the corresponding configuration needs to be removed from the sudoers file:
-- Craig Dunn | http://www.craigdunn.org Yahoo/Skype: craigrdunn | Twitter: @crayfishX
On 21/03/2012 11:48, John Kennedy wrote:I would suggest looking at Augeas..Hello all,
I am fairly new to Puppet but learning.
I know what I want to do can be done I just can not get things to go right...
We want to start using the capability of sudo to look in /etc/sudoers.d to get user specific sudo permissions. Before we add a User_Alias file, the corresponding configuration needs to be removed from the sudoers file:
http://augeas.net
Theres some useful documentation about using it with Puppet here (including some examples around sudoers)
http://projects.puppetlabs.com/projects/1/wiki/puppet_augeas
Regards
Craig
Have you considered using sed instead of perl? It's lighter-weight> - NOTE: I am adding and removing the #includedir line for testing...
>
> What needs to be changed to get this to work?
and very good at this sort of thing.
Personally, however, I would be looking at using a File resource to
manage the *whole file* instead of filtering out a few lines.
John
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
On Thursday, March 22, 2012 at 6:23 AM, John Kennedy wrote:
On Thu, Mar 22, 2012 at 13:02, jcbollinger <John.Bo...@stjude.org> wrote:Have you considered using sed instead of perl? It's lighter-weight> - NOTE: I am adding and removing the #includedir line for testing...
>
> What needs to be changed to get this to work?
and very good at this sort of thing.
Personally, however, I would be looking at using a File resource to
manage the *whole file* instead of filtering out a few lines.
Hi,
> Have you looked at the 'file_line' type in Puppet's stdlib?
> https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/type
> /file_line.rb
What's Puppet's stdlib? Is it something bundled inside? Are there any other types available?
I can't see the file_line type in the manual:
http://docs.puppetlabs.com/references/2.7.0/type.html
Thanks!
Pablo
--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.
-- Luke Bigum Information Systems Ph: +44 (0) 20 3192 2520 luke....@lmax.com | http://www.lmax.com LMAX, Yellow Building, 1A Nicholas Road, London W11 4AN
On Thursday, March 22, 2012 at 6:23 AM, John Kennedy wrote:
On Thu, Mar 22, 2012 at 13:02, jcbollinger <John.Bo...@stjude.org> wrote:Have you considered using sed instead of perl? It's lighter-weight> - NOTE: I am adding and removing the #includedir line for testing...
>
> What needs to be changed to get this to work?
and very good at this sort of thing.
Personally, however, I would be looking at using a File resource to
manage the *whole file* instead of filtering out a few lines.
Have you looked at the 'file_line' type in Puppet's stdlib? https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/type/file_line.rb
I can see where 'file_line' will add a line but I don't know enough ruby to know, will it remove a line that does exist?
One (hopefully) last question...How do I take the file_line.rb file and put it so puppet recognises it? Do I do that with a define or can I just take the file and place it somewhere for it to work?