I have copied the simple text snippets into a pp file and set a host to
attempt to add lines, but regardless if the line is there or not, it still
adds it...
what am I doing wrong?
in definitions/linetests.pp:
define append_if_no_such_line($file, $line) {
exec { "echo ''$line'' >>
''$file''":
unless => "grep -qe ''$line'' --
file",
path => "/bin:/usr/bin:/usr/local/bin",
}
}
define prepend_if_no_such_line($file, $line) {
exec { "/usr/bin/perl -p0i -e ''s/^/$line\n/;''
''$file''":
unless => "grep -Fxqe ''$line''
''file''",
path => "/bin:/usr/bin:/usr/local/bin",
}
}
in classes/fileTest.pp:
class fileTest {
file { "/puppetTestFile":
ensure => present,
}
append_if_no_such_line { appendtest:
file => "/puppetTestFile",
line => "this is the append test",
}
prepend_if_no_such_line { prependtest:
file => "/puppetTestFile",
line => "this is the prepend test",
}
}
I always get this success in messages:
Aug 20 14:41:57 assault puppetd[16036]:
(//assault/filetest/prepend_if_no_such_line[prependtest]/Exec[/usr/bin/perl
-p0i -e ''s/^/this is the prepend test /;''
''/puppetTestFile'']/returns)
executed successfully
Aug 20 14:41:57 assault puppetd[16036]:
(//assault/filetest/append_if_no_such_line[appendtest]/Exec[echo ''this
is
the append test'' >> ''/puppetTestFile'']/returns)
executed successfully
I''m new to this (puppet and Ruby) so be kind.
JR
_______________________________________________
Puppet-users mailing list
Puppet-users@madstop.com
https://mail.madstop.com/mailman/listinfo/puppet-users