<div dir="ltr"><br><br><div class="gmail_quote">On Fri, Aug 1, 2008 at 12:17 AM, Kjetil Torgrim Homme <span dir="ltr"><<a href="mailto:kjetilho@linpro.no">kjetilho@linpro.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Bryan Kearney <<a href="mailto:bkearney@redhat.com">bkearney@redhat.com</a>> writes:<br>
> I am going to work on getting this into the puppet common modules,<br>
> but if you are using puppet we have a module [1] which exposes<br>
> augeas to puppet. It accepts a set of changes as either a single<br>
> string, or an array of strings. It replaces using regular<br>
> expressions to edit files, or to put an entire file into puppet as a<br>
> template.<br>
<br>
</div>can you give us an example or two?<br>
<br>
it's with Puppet I want to use Augeas, and what I had envisioned is<br>
something like<br>
<br>
   editfile { "/etc/my.cnf":<br>
      lens => 'generic-ini,<br>
      set => '/mysqld/query_cache_limit=1048576',<br>
      rm => '/mysqld/log-slow-queries',<br>
  }<br>
</blockquote><div><br><br>Why specify the lens? I don't think you can force the lens with the augeas API, and it's not necessary since augeas knows what lens to use on what file.<br><br>Btw, my.cnf is not a standard inifile, since it uses flags. I'm currently working on it, based on inifile.aug + a flag entry.<br>
<br><br>I'm personnaly for keeping the xpath syntax in puppet, because otherwise we lose a lot of functionality from augeas, so I was thinking of something like :<br><br><br>augeas { <br><br>"/files/etc/my.cnf/mysqld/query_cache_limit":<br>
   action => set,<br>   value  => "1048576",<br>   notify => Service["mysql"];<br><br>"/files/etc/my.cnf/mysqld/log-slow-queries":<br>   action => rm,<br>   notify => Service["mysql"];<br>
<br>"/files/etc/logrotate.d/apache2/rule[1]":<br>   action => mv,<br>   newnode => "/files/etc/logrotate.d/apache2/rule[2]",<br>   notify => Service["logrotate"];<br><br>}<br><br><br>
I believe using an "action" parameter is better than using "set", "insert", "rm", etc. because using the latter would make you think that you can perform several actions in one puppet call, which is not possible (or I don't know how to do it at least :) ). <br>
<br>Calling the object "augeas" makes it clear that it's an an editfile syntax like in Cfengine, but specifically an augeas syntax, and that this object is likely to evolve with the augeas API.<br><br><br>When it comes to setting several values with one call, I think it is the task of specific constructed types in puppet, like :<br>
<br>define mysql::server ( $query_cache_limit="123456", $log-slow-queries, other parameters...) {<br><br>blah blah <br>package management<br>blah blah<br><br><br>    augeas { <br>        "/files/etc/mysql.cnf/query_cache_limit":<br>
           action => set,<br>           value  => "123456";<br><br>        "/files/etc/my.cnf/log-slow-queries":<br>           action => rm;<br>    }<br><br>}<br><br><br>This type could check for values, and do :<br>
   - set the value if the value is defined<br>   - rm the value if the value is not defined<br><br><br>Or there could be a keyword to tell the type to delete the value...<br><br><br>editfile { "/etc/ssh/sshd_config":<br>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
      lens => 'sshd,<br>
      match => '/sshd/AcceptEnv/*',<br>
      rm => 'match',<br>
  }</blockquote><div><br><br>using the xpath format directly in the action would lead to this aswell :<br><br>augeas { "/files/etc/ssh/sshd_config/sshd/AcceptEnv/*":<br>    action => rm;<br>}<br><br><br>I'm for keeping the full path (including /files) because there might be interesting things to grab in /augeas aswell (sanity of a file, last created node - as discussed with David lately, etc.). It would be too bad to restrict the API in puppet and later one have to work around to access values that were available from the beginning.<br>
<br>Of course, it forces puppet users that want to use the augeas object to learn a bit about augeas, but this is not bad. After all, if they plan to manage their config file with the augeas object, they might very well have to write an augeas lens for them!<br>
<br><br>Btw, I'm forwarding this conversation to the puppet-dev group to have more insight/ideas from other puppet experts.<br><br><br><br>Raphaël<br><br><br></div></div></div>