Hi, I really think you want to use the file_line type from the puppetlabs-stdlib module.
Thanks, Spencer On Tue, Mar 25, 2014 at 10:11 AM, puppetstan <[email protected]>wrote: > Hi, > > I have 2 problems with lines functions : the first and the second ;) > > My configuration : > > I create line functions (present, absent...) > > 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}'", > logoutput => true > } > } > absent : { > exec { > "/bin/grep -vFx '${line}' '${file}' | tee '${file}' > > /dev/null 2>&1" : > onlyif => "/bin/grep -qFx '${line}' '${file}'", > logoutput => true > } > } > ... > ... > ... > > > Il create a profil class with line function > > > class profil::redhat { > line {'alias vim': > file => '/root/.bashrc', > line => "alias vi=\'vim\'", > ensure => present > } > line {'alias color': > file => '/root/.bashrc', > line => "alias grep=\'grep --color\'", > ensure => present > } > } > > > First problem : a single quote problem > > My result in my '/root/.bashrc' file, i would like > > alias grep='grep --color' > alias vi='vim' > > but i have > > alias grep=grep --color > alias vi=vim > > Can you have an idea to protect single quote? > > > Second problem : my manifect consider that *alias grep=grep --color* > is absent in my '/root/.bashrc' file but is present so he create this > line all the time > > > alias grep=grep --color > alias grep=grep --color > alias grep=grep --color > alias grep=grep --color > > I think it's the space beetween grep and --color > > can you have an idea > > thanks a lot in adavace > regards > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/puppet-users/3942e61e-4391-4f49-9309-9b3c3dc5c535%40googlegroups.com<https://groups.google.com/d/msgid/puppet-users/3942e61e-4391-4f49-9309-9b3c3dc5c535%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Spencer Krum (619)-980-7820 -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/CADt6FWP25PHG9dCNwej53rh7q2Rmee1D8WHSU-_B-7-3UhQYWA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
