<div dir="ltr"><br><br><div class="gmail_quote">On Fri, Aug 1, 2008 at 1:21 PM, 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;">
"Raphaël Pinson" <<a href="mailto:raphink@gmail.com">raphink@gmail.com</a>> writes:<br>
> [Kjetil Torgrim Homme]:<br>
<div class="Ih2E3d">><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>
><br>
> Why specify the lens? I don't think you can force the lens with the<br>
> augeas API, and it's not necessary since augeas knows what lens to<br>
> use on what file.<br>
<br>
</div>I don't really want the "holistic" view, I prefer Augeas to work on<br>
individual files.  keeps it simple, and also much faster, since only<br>
the files you're going to edit will be parsed.  consider if I wanted<br>
to edit ~mysql/.bashrc -- should Augeas pull in *all* user's .bashrc<br>
in its tree?  that would not be a pretty sight on a system with LDAP<br>
and NFS :-)</blockquote><div><br><br>I don't know how to do that though. The association lens<=>file is inner to the lens itself. I don't think it currently possible to force it in the API. Setting your file as the root in augeas doesn't work (at least in augtool it doesnt work):<br>
<br> $ augtool -r /etc/<a href="http://dput.cf">dput.cf</a><br>augtool> ls /<br>augeas/ = (none)<br><br><br>In any case, I think the augeas API would be initialized only once per puppet call, which means that all known files have to be added to the augeas tree. Once they are in the tree, it doesn't make it any slower to access the full tree.<br>
 <br><br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
also, I don't want to hardcode the location of configuration files in<br>
the lens -- it can vary from system to system.  some system has this<br>
or that file in /etc/mysql, some other system in /usr/lib/mysql, and a<br>
third system may have multiple independent MySQL-instances.  that's<br>
information which should be in Puppet, not Augeas, IMHO.</blockquote><div><br><br>That might be something to improve in augeas, then.<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
> Btw, my.cnf is not a standard inifile, since it uses flags. I'm<br><div class="Ih2E3d">
> currently working on it, based on inifile.aug + a flag entry.<br>
<br>
</div>yeah, I know it's not a complete fit, it was just an example.<br>
<div class="Ih2E3d"><br>
> I'm personnaly for keeping the xpath syntax in puppet, because<br>
> otherwise we lose a lot of functionality from augeas, so I was<br>
> thinking of something like :<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>
</div>I agree this is nicer.  it doesn't identify the file, which I want,<br>
though.  it also is unordered, so be aware -- what node would<br>
"/files/etc/logrotate.d/apache2/rule[2]": action => rm remove ?<br>
<div class="Ih2E3d"></div></blockquote><div><br><br>Yes, it is unordered in this case, but ordering it is a matter or adding dependencies, like <br><br>before => Augeas["/files/etc/logrotate.d/apache2/rule[1]"]<br>
<br><br>Actually, this makes me think that it might be better to give an independent name to the puppet object, in case I want to use a path several times (which is not possible in puppet if the path is the object name), like :<br>
<br>augeas {<br>    "set query cache limit":<br>        path    => "/files/etc/my.cnf/mysqld/query_cache_limit",<br>        ensure => "present",<br>        value   => "1048576";<br>
<br>    "remove log slow queries":<br>        path    => "/files/etc/my.cnf/mysqld/log-slow-queries",<br>        ensure => absent,<br>        require => Augeas["set query cache limit"],<br>
        notify   => Service["mysql"];<br>}<br><br><br><br>There is another thing to think about also: should there be a save for each command, or only in the end of the session (which might fail more likely)?<br>
<br></div><div> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">> When it comes to setting several values with one call, I think it is<br>
<div>
> 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>
>     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>
> 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> </div></blockquote><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">
<br>
</div>I don't see how the define is used here.<br>
<div class="Ih2E3d"></div></blockquote><div><br><br>It is not here, this was a thing-to-be-implemented kind of comment :)<br><br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
perhaps separate editfile and augeas providers would make sense for<br>
this reason, ie. use editfile for standalone edits, and augeas when<br>
you want to pull the entire configuration into the tree.<br>
<font color="#888888"></font></blockquote><div><br>Yes, and also editfiles allows to modify virtually any file in the system (binary files might be a bit tricky ;)) whereas augeas needs lenses for that, so I think the distinction has to be clear.<br>
<br><br><br>Raphaël<br><br><br></div></div><br></div>