Look into using "file_line," it's part of stdlib.

https://forge.puppetlabs.com/puppetlabs/stdlib

If you want to check for an existing line, using an "exec" you can use
"onlyif" or "unless."

Something like:

unless => "grep myline /path/to/file",

http://docs.puppetlabs.com/references/latest/type.html#exec

Kent


On Mon, Apr 21, 2014 at 10:18 AM, Dan Pasacrita <whitewind...@gmail.com>wrote:

> Hi everyone, I'm pretty new to puppet, and I was wondering if you guys to
> help me with something pretty basic. I'm attempting to write a module that
> will check a text file for a certain line of text, and if it doesn't find
> it, to add a that content in a new line.
>
> I'm pretty sure I can add the new line using exec to run echo "content" >>
> file.txt, but checking the file for said content has me completely stumped.
> What can I do here?
>
> --
> 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/ff5d0baa-7adc-4162-983a-67bb010a3fb1%40googlegroups.com<https://groups.google.com/d/msgid/puppet-users/ff5d0baa-7adc-4162-983a-67bb010a3fb1%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Kent Brede

-- 
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/CA%2BnSE3-qg6oOd1Ft07Vf0XNO01Lw2cV-bpseW34xas1XsWy7MQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to