I''m reading about Augeas to see what can be done with it, and with the new ''augeas'' resource type in 0.24.7. So far I have only played using augtool, not the Puppet integration, but I have a few questions: 1. Is it possible to specify what lens to use for editing a certain file? Can I for instance tell it to use the sshd lens to edit an sshd config file in a non-standard place? Or to use the shellvars lens to edit /etc/sysconfig/sendmail (the version of Augeas in Fedora 9 happily edits lots of other files in /etc/sysconfig, but not the sendmail file). Do I have to write a new lens for this? 2. How do I modify an entry in the tree, as opposed to rewrite it with a fixed string? For example, the grub.conf file has lines saying kernel /vmlinuz-2.6.27.5-41.fc9.x86_64 ro root=/dev/sda2 rhgb quiet and I want to remove the words "rhgb" and "quiet". Just doing set /files/etc/grub.conf/title[1]/kernel "/vmlinuz-2.6.27.5-41.fc9.x86_64 ro root=/dev/sda2" is the wrong answer, because I might not know what "/dev/sda2" should be on every system, and I certainly do not know what the version of the kernel should be. You might think that I could use the $kernelrelease fact, but the kernel line I want to modify might not be for the kernel that is actually running. 3. Continuing the above grub.conf example, there may be an unknown number of kernel lines that need to be modified. How do I get augeas to modify all of them in the above way? 4. In the /etc/logrotate.conf file in Fedora and CentOS, there is an entry on the form: /var/log/wtmp { monthly create 0664 root utmp rotate 1 } I want to comment out, or remove entirely, that entry. I can find it with match /files/etc/logrotate.conf/*/file "/var/log/wtmp" which right now happens to give me /files/etc/logrotate.conf/rule[1]/file After finding that information, I want to do rm /files/etc/logrotate.conf/rule[1] but how do I feed the information from the match back to the rm command? That will do for now. :-) /Bellman --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
Thomas Bellman wrote:> I''m reading about Augeas to see what can be done with it, and > with the new ''augeas'' resource type in 0.24.7. So far I have > only played using augtool, not the Puppet integration, but I > have a few questions:The type is basically a wrapper around augtool. So.. the answer may be "the same way". However, it may help to map the parameters in the type to the augtool. Here they are: * PARAMATER | Augtool Equivilant * root | augtool -r option * load_path | augtool -I option * type_check | augtool -c option * name | Nop real mapping. Used becuase puppet needs an ID * changes | maps to the command in augtool. * Contxt | No real mapping. It is used to avoid typing the complete path name * onlyif | No real mapping, used to control processing Let me address some more below. David Lutterkort may be able to provide better detail or approaches.> > > 1. Is it possible to specify what lens to use for editing a > certain file? Can I for instance tell it to use the sshd lens > to edit an sshd config file in a non-standard place? Or to > use the shellvars lens to edit /etc/sysconfig/sendmail (the > version of Augeas in Fedora 9 happily edits lots of other > files in /etc/sysconfig, but not the sendmail file). Do I > have to write a new lens for this?I believe you would have to copy the lens to a new location, and use the load_path parameter.> > > 2. How do I modify an entry in the tree, as opposed to rewrite it > with a fixed string? For example, the grub.conf file has > lines saying > > kernel /vmlinuz-2.6.27.5-41.fc9.x86_64 ro root=/dev/sda2 rhgb quiet > > and I want to remove the words "rhgb" and "quiet". Just doing > > set /files/etc/grub.conf/title[1]/kernel > "/vmlinuz-2.6.27.5-41.fc9.x86_64 ro root=/dev/sda2" > > is the wrong answer, because I might not know what "/dev/sda2" > should be on every system, and I certainly do not know what > the version of the kernel should be. > > You might think that I could use the $kernelrelease fact, but > the kernel line I want to modify might not be for the kernel > that is actually running.I believe this logic would need to be outside of the type creating the line in a variable. Then you can set the variable in the augeas type.> > > 3. Continuing the above grub.conf example, there may be an unknown > number of kernel lines that need to be modified. How do I get > augeas to modify all of them in the above way?I believe you can set using wildcards to support this.> > > 4. In the /etc/logrotate.conf file in Fedora and CentOS, there is > an entry on the form: > > /var/log/wtmp { > monthly > create 0664 root utmp > rotate 1 > } > > I want to comment out, or remove entirely, that entry. I can > find it with > > match /files/etc/logrotate.conf/*/file "/var/log/wtmp" > > which right now happens to give me > > /files/etc/logrotate.conf/rule[1]/file > > After finding that information, I want to do > > rm /files/etc/logrotate.conf/rule[1] > > but how do I feed the information from the match back to the > rm command?I dont know of a way off hand. Lemme bug David about this one. -- bk --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, 2008-12-16 at 09:52 +0100, Thomas Bellman wrote:> 1. Is it possible to specify what lens to use for editing a > certain file? Can I for instance tell it to use the sshd lens > to edit an sshd config file in a non-standard place?Add the directory with your custom lens to the load_path; augeas will then load that lens instead of the default one.> Or to > use the shellvars lens to edit /etc/sysconfig/sendmail (the > version of Augeas in Fedora 9 happily edits lots of other > files in /etc/sysconfig, but not the sendmail file). Do I > have to write a new lens for this?That was an oversight; I just comitted a fix to add that file in shellvars.aug. For now, you can work around that by adding a module like module Sendmail autoload xfm let xfm = transform Shellvars.lns (incl "/etc/sysconfig/sendmail")> 2. How do I modify an entry in the tree, as opposed to rewrite it > with a fixed string? For example, the grub.conf file has > lines saying > > kernel /vmlinuz-2.6.27.5-41.fc9.x86_64 ro root=/dev/sda2 rhgb quiet > > and I want to remove the words "rhgb" and "quiet". Just doing > > set /files/etc/grub.conf/title[1]/kernel > "/vmlinuz-2.6.27.5-41.fc9.x86_64 ro root=/dev/sda2" > > is the wrong answer, because I might not know what "/dev/sda2" > should be on every system, and I certainly do not know what > the version of the kernel should be. > > You might think that I could use the $kernelrelease fact, but > the kernel line I want to modify might not be for the kernel > that is actually running.Yeah, that is a problem. It''s not quite a solution, but to allow such operations we''d need to change the grub lens to split the kernel line into individual arguments, so that you get something like /files/etc/grub.conf/title[1]/kernel = "/vmlinuz-2.6.27.5-41.fc9.x86_64" /files/etc/grub.conf/title[1]/kernel/arg = "ro" /files/etc/grub.conf/title[1]/kernel/arg = "root=/dev/sda2" /files/etc/grub.conf/title[1]/kernel/arg = "rhgb" /files/etc/grub.conf/title[1]/kernel/arg = "quiet" Right now, you''re still stuck even with that - I am working on extending the query language so that you could remove the "rhgb" arg with something like rm /files/etc/grub.conf/title/kernel[value() = "/vmlinuz-2.6.27.5-41.fc9.x86_64"]/arg[value() = "rhgb"] and do the same for all kernels with rm /files/etc/grub.conf/title/kernel/arg[value() = "rhgb"] but unfortunately, that isn''t quite finished yet.> 4. In the /etc/logrotate.conf file in Fedora and CentOS, there is > an entry on the form: > > /var/log/wtmp { > monthly > create 0664 root utmp > rotate 1 > } > > I want to comment out, or remove entirely, that entry. I can > find it with > > match /files/etc/logrotate.conf/*/file "/var/log/wtmp" > > which right now happens to give me > > /files/etc/logrotate.conf/rule[1]/file > > After finding that information, I want to do > > rm /files/etc/logrotate.conf/rule[1] > > but how do I feed the information from the match back to the > rm command?That will also require the XPath extension I am working on, so that you can say rm /files/etc/logrotate.conf/rule[file = "/var/log/wtmp"] David --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---
David Lutterkort wrote:> On Tue, 2008-12-16 at 09:52 +0100, Thomas Bellman wrote:>> 1. Is it possible to specify what lens to use for editing a >> certain file? Can I for instance tell it to use the sshd lens >> to edit an sshd config file in a non-standard place? > > Add the directory with your custom lens to the load_path; augeas will > then load that lens instead of the default one. > >> Or to >> use the shellvars lens to edit /etc/sysconfig/sendmail (the >> version of Augeas in Fedora 9 happily edits lots of other >> files in /etc/sysconfig, but not the sendmail file). Do I >> have to write a new lens for this? > > That was an oversight; I just comitted a fix to add that file in > shellvars.aug. > > For now, you can work around that by adding a module like > module Sendmail > autoload xfm > > let xfm = transform Shellvars.lns (incl "/etc/sysconfig/sendmail") >As I feared. At least I don''t have to maintain full copies of the sshd or shellvars lenses. Still, it would be very nice to be able to just tell augeas to use a specific lens for a specific file, without having to write a custom lens (even if a very small one). In Puppet, I think a good interface would be something like: augeas { globus-sshd-hostauth: file => "/opt/globus/etc/ssh/sshd_config", lens => "sshd", changes => [ "set /HostbasedAuthentication yes" ]; } to tell Augeas to use the normal sshd lens when editing the file /opt/globus/etc/ssh/sshd_config. That would make it much more convenient to use. (Yes, I know I can use the root parameter in this specific case, but I hope you see the principle beyond my example. I''m quite confident that I will *always* be able to find an /etc/sysconfig file from an obscure package that you haven''t yet added to shellvars.aug. :-)>> [...About removing the "rhgb" words from kernel lines in grub.conf...]> Yeah, that is a problem. It''s not quite a solution, but to allow such > operations we''d need to change the grub lens to split the kernel line > into individual arguments, so that you get something like > > /files/etc/grub.conf/title[1]/kernel = "/vmlinuz-2.6.27.5-41.fc9.x86_64" > /files/etc/grub.conf/title[1]/kernel/arg = "ro" > /files/etc/grub.conf/title[1]/kernel/arg = "root=/dev/sda2" > /files/etc/grub.conf/title[1]/kernel/arg = "rhgb" > /files/etc/grub.conf/title[1]/kernel/arg = "quiet" > > Right now, you''re still stuck even with that - I am working on extending > the query language so that you could remove the "rhgb" arg with > something like > > rm /files/etc/grub.conf/title/kernel[value() = "/vmlinuz-2.6.27.5-41.fc9.x86_64"]/arg[value() = "rhgb"] > > and do the same for all kernels with > > rm /files/etc/grub.conf/title/kernel/arg[value() = "rhgb"] > > but unfortunately, that isn''t quite finished yet.Another alternative might be to be able to do regexp replacements on values. Something like transform .../title[1]/kernel "vmlinuz-(.*) rhgb(.*)" "vmlinuz-\\1\\2" Something like that could be useful even with your arg[value()==...] extension above. There will probably *always* be cases where the tree created by Augeas is not quite enough. (However, we then get to the joys of applying three levels of quoting: one for string literals in Puppet, one for string literals in Augeas, and one for regexps. It''s bad enough that we have already have the two first levels to deal with. I believe we need to think a bit more about what syntax we want in Puppet for Augeas.)> That will also require the XPath extension I am working on, so that you > can say > > rm /files/etc/logrotate.conf/rule[file = "/var/log/wtmp"]OK. I''m looking forward to that, then. Luckily for me, I have already solved my current file editing needs, with a couple of custom Puppet types that do regexp-based line editing. But it will be nice to be able to do all I want without resorting to custom extensions. In many cases, using Augeas will be a much cleaner way to do what I want, also. Keep up the good work! /Bellman --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com To unsubscribe from this group, send email to puppet-users+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en -~----------~----~----~----~------~----~------~--~---