Re: [Puppet Users] Re: Augeas lens to change an arbitrary line in a file?
On 04/24/14 06:37, Ian Mortimer wrote: On 04/23/14 18:29, Joachim Schrod wrote: I don't understand why the match regex must match the line value. Your match needs to be: match = '^(% )*/DEFAULTPAPERSIZE \(a4\)', It has to match the line value, otherwise on the next puppet run your modified line won't match and puppet will insert a new (unwanted) line at the end of the file . Ah, match replaces the base functionality that matches the full line, including whitespace at the beginning and end. If the line is not contained in the given file, Puppet will add the line to ensure the desired state. I thought the match regex would be an _additional_ test, and that the check for existance of the line would be done nevertheless. If anybody here has write access to the file_line docs: It would be nice to note that in the description of match. For this newbie, this was not clear. Thanks for the explanation, Joachim -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod, Roedermark, Germany Email: jsch...@acm.org -- 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/ljbflv%24bpa%241%40ger.gmane.org. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] Re: Augeas lens to change an arbitrary line in a file?
On 04/23/14 07:54, Gabriel Filion wrote: On 22/04/14 08:20 PM, Joachim Schrod wrote: # Ghostscript default paper size file_line { 'Ghostscript A4' : path = '/usr/share/ghostscript/9.05/Resource/Init/gs_init.ps', match = '^% /DEFAULTPAPERSIZE \(a4\)', line = '/DEFAULTPAPERSIZE (a4) def' } The error message is Error: Failed to apply catalog: Validation of File_line[Ghostscript A4] failed: When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter at /etc/puppet/modules/npc/manifests/commons.pp:30 Wrapped exception: When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter maybe by regex it means that you need to enclose it in / characters: http://www.ruby-doc.org/core-2.1.1/Regexp.html e.g. : match = /^% /DEFAULTPAPERSIZE \(a4\)/, I'm not sure whether you need the quotes, too.. I'd try without first.. Without quotes, the error message is Syntax error at '/'; expected '}' With quotes and slashes, the error message is the same as before, quoted above. I don't understand why the match regex must match the line value. Joachim -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod, Roedermark, Germany Email: jsch...@acm.org -- 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/lj7tkc%24k32%241%40ger.gmane.org. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] Re: Augeas lens to change an arbitrary line in a file?
On 04/23/14 18:29, Joachim Schrod wrote: I don't understand why the match regex must match the line value. Your match needs to be: match = '^(% )*/DEFAULTPAPERSIZE \(a4\)', It has to match the line value, otherwise on the next puppet run your modified line won't match and puppet will insert a new (unwanted) line at the end of the file . -- Ian -- 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/53589509.5070509%40uq.edu.au. For more options, visit https://groups.google.com/d/optout.
[Puppet Users] Re: Augeas lens to change an arbitrary line in a file?
There's also the file_line resource that's available with the std lib module, that might work for you as well. On Monday, April 21, 2014 3:25:13 PM UTC-7, Joachim Schrod wrote: Hi, I'm new to Puppet, and also new to Augeas. I want to change a line in a file. In particular, the file is /usr/share/ghostscript/${gs_version}/Resource/Init/gs_init.ps and the line is % /DEFAULTPAPERSIZE (a4) def that I want to change into /DEFAULTPAPERSIZE (a4) def Is Augeas the right tool for such a task? I looked through its available lenses, but there ain't no Postscript lens. Of course, the other approach would be to use an exec resource to change that line. What is best practice? Joachim -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod, Roedermark, Germany Email: jsc...@acm.org javascript: -- 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/6b6b743b-3a6b-45a0-bc40-eec291688374%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] Re: Augeas lens to change an arbitrary line in a file?
I'm no expert with augeas but after looking at the gs_init.ps file, I don't know of any current lens that could be easily modified to work with it. I agree with Mike, I'd either use file_line or an exec. File_line is part of stdlib. Click on the types tab on this page for an example. https://forge.puppetlabs.com/puppetlabs/stdlib Kent On Mon, Apr 21, 2014 at 11:32 PM, Mike Langhorst mike.langho...@gmail.comwrote: There's also the file_line resource that's available with the std lib module, that might work for you as well. On Monday, April 21, 2014 3:25:13 PM UTC-7, Joachim Schrod wrote: Hi, I'm new to Puppet, and also new to Augeas. I want to change a line in a file. In particular, the file is /usr/share/ghostscript/${gs_version}/Resource/Init/gs_init.ps and the line is % /DEFAULTPAPERSIZE (a4) def that I want to change into /DEFAULTPAPERSIZE (a4) def Is Augeas the right tool for such a task? I looked through its available lenses, but there ain't no Postscript lens. Of course, the other approach would be to use an exec resource to change that line. What is best practice? Joachim -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod, Roedermark, Germany Email: jsc...@acm.org -- 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/6b6b743b-3a6b-45a0-bc40-eec291688374%40googlegroups.comhttps://groups.google.com/d/msgid/puppet-users/6b6b743b-3a6b-45a0-bc40-eec291688374%40googlegroups.com?utm_medium=emailutm_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-fiXAa9OZLppS0EwK5Uif5L7Rrcd1e22zipO84tyzJjQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] Re: Augeas lens to change an arbitrary line in a file?
On 04/22/14 18:14, Kenton Brede wrote: I'm no expert with augeas but after looking at the gs_init.ps http://gs_init.ps file, I don't know of any current lens that could be easily modified to work with it. I agree with Mike, I'd either use file_line or an exec. File_line is part of stdlib. Click on the types tab on this page for an example. https://forge.puppetlabs.com/puppetlabs/stdlib Thanks to Mike and to you for that hint. Well, but it doesn't work as I expected. I use the following resource declaration: # Ghostscript default paper size file_line { 'Ghostscript A4' : path = '/usr/share/ghostscript/9.05/Resource/Init/gs_init.ps', match = '^% /DEFAULTPAPERSIZE \(a4\)', line = '/DEFAULTPAPERSIZE (a4) def' } The error message is Error: Failed to apply catalog: Validation of File_line[Ghostscript A4] failed: When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter at /etc/puppet/modules/npc/manifests/commons.pp:30 Wrapped exception: When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter According to https://forge.puppetlabs.com/puppetlabs/stdlib; tab Types, it's match An optional regular expression to run against existing lines in the file;\nif a match is found, we replace that line rather than adding a new line. line I don't understand that error message. Hopefully, my intent is clear: As long as the default GS paper size is commented out, I want a replacement of that line with the new line. According to (my understanding) of stdlib::file_line, that should be the way it works: -- If the commented-out line is matched, it's substituted by the new line. -- If it's not matched, the new line is added unless it's present. That's my interpretation of the documentation. AFAICS, reality beats me. match wants a line as a result that's the outcome of the change that match is the solicitor to. I'd appreciate any hints or explanations what I'm doing wrong. Best, Joachim FWIW: puppet 3.3.1 on openSUSE. (open)SUSE is abandanoned by / has abandonded Puppet. The so-called maintainer announced that he was forced to take over the packages due to a leaving collegue and is looking for a new community-based maintainer. Nobody stood up. (Not too suprising, deployment management is not really the realm of laptop-minded developers like many people that we find at openSUSE. Data-center topics like Puppet doesn't seem to be important there.) Tickets (even with patches; e.g., by me) are not worked at / acted upon any more. Thus, I would prefer a hint or a direction that works with an older version of Puppet (3.3.x) as well. If that's not possible, the statement that it works with 3.5.x is fine as well -- that simply means that we have to check if our customer's plan to use Puppet is still ok with (open)SUSE, if they will fund it. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- Joachim Schrod, Roedermark, Germany Email: jsch...@acm.org -- 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/lj710p%2437r%241%40ger.gmane.org. For more options, visit https://groups.google.com/d/optout.
Re: [Puppet Users] Re: Augeas lens to change an arbitrary line in a file?
On 22/04/14 08:20 PM, Joachim Schrod wrote: # Ghostscript default paper size file_line { 'Ghostscript A4' : path = '/usr/share/ghostscript/9.05/Resource/Init/gs_init.ps', match = '^% /DEFAULTPAPERSIZE \(a4\)', line = '/DEFAULTPAPERSIZE (a4) def' } The error message is Error: Failed to apply catalog: Validation of File_line[Ghostscript A4] failed: When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter at /etc/puppet/modules/npc/manifests/commons.pp:30 Wrapped exception: When providing a 'match' parameter, the value must be a regex that matches against the value of your 'line' parameter maybe by regex it means that you need to enclose it in / characters: http://www.ruby-doc.org/core-2.1.1/Regexp.html e.g. : match = /^% /DEFAULTPAPERSIZE \(a4\)/, I'm not sure whether you need the quotes, too.. I'd try without first.. -- Gabriel Filion signature.asc Description: OpenPGP digital signature