On Tue, Aug 19, 2014 at 08:01:40AM -0700, Helen Paterson wrote:
> Hi,
> I cannot get the regex to work in puppet for "file_line" it work in a
> regex tool
> file_line { "applicationHost.config":
> ensure => 'present',
> path =>
> 'c:/windows/sysnative/inetsrv/config/applicationHost.config',
> match => '\s{1,12}<add name="Public" .*',
> line => '<add name="Public" autoStart="true"
> startMode="AlwaysRunning" managedRuntimeVersion="v4.0">',
Your line here doesn't include spaces at the start of the line. Your regex wants minimum 1 and maximum 12 spaces to match. The regex will never find the line after replacing it once, if I read this correctly.
> however below works if i remove spaces from the file for testing
> file_line { "applicationHost.config":
> ensure => 'present',
> path =>
> 'c:/windows/sysnative/inetsrv/config/applicationHost.config',
> match => '<add name="Public" .*',
> line => '<add name="Public" autoStart="true"
> startMode="AlwaysRunning" managedRuntimeVersion="v4.0">',
>
> the file has 12 spaces in front of the text.
If you're able to manage a single line with this string in a file with no other lines, that may help show what's going on?
This may assist with regexes in puppet:
https://docs.puppetlabs.com/puppet/latest/reference/lang_datatypes.html#regular-expressions
And this manifest:
if ' ' =~ /\s/ {
notice('matches #1!')
}
if ' ' =~ /\s{1,12}/ {
notice('matches #2!')
}
if '<' =~ /\s{1,12}/ {
notice('matches #3!')
}
For me it only prints about the match for 1 and 2, not 3.
> --
> 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 [1]
puppet-users...@googlegroups.com.
> To view this discussion on the web visit
> [2]
https://groups.google.com/d/msgid/puppet-users/3f4376c4-d0aa-4c73-9364-1e64483f944c%40googlegroups.com.
> For more options, visit [3]
https://groups.google.com/d/optout.
>
> References
>
> Visible links
> 1. mailto:
puppet-users...@googlegroups.com
> 2.
https://groups.google.com/d/msgid/puppet-users/3f4376c4-d0aa-4c73-9364-1e64483f944c%40googlegroups.com?utm_medium=email&utm_source=footer
> 3.
https://groups.google.com/d/optout