can puppet check if the string is present in file

2,305 views
Skip to first unread message

vicki

unread,
Mar 26, 2012, 6:34:21 PM3/26/12
to Puppet Users
Hello,
I need to add the JVM arguments to the script based on some condition.
First I need to check whether the string representing these args is
already there. Can Puppet check the existence a substring and return
with a code just like java indexOf(substr) does?

Thank you.
Vicki

Gary Larizza

unread,
Mar 26, 2012, 6:44:39 PM3/26/12
to puppet...@googlegroups.com
Look at the 'file_line' custom type in the Puppetlabs Stdlib. The documentation in the file should assist with its usage.

https://github.com/puppetlabs/puppetlabs-stdlib/blob/master/lib/puppet/type/file_line.rb
> --
> 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.
>
>

--

Gary Larizza
Professional Services Engineer
Puppet Labs

vicki

unread,
Mar 26, 2012, 7:40:45 PM3/26/12
to puppet...@googlegroups.com
Thank you Gary for your reply. It is actually the substring of the line that I have to check. Here's the sed command that I use:

sed 's/^JVM_OPTS=\"/&\-Xbootclasspath\/p\:\/eng\/x.jar  <sed_test.sh >sed_test_new.sh

As you can see, I am matching this substring   JVM_OPTS+"  at the beginning of the JVM_OPTS line in the script, and inserting my bootclasspath argument right after. I am going to look at your code, and see if I can either get it to work for my case, or come up with something that works.

Thanks!!
Vicki
Reply all
Reply to author
Forward
0 new messages