<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jul 28, 2015 at 8:09 PM, Mickaël Canévet <span dir="ltr"><<a href="mailto:mickael.canevet@gmail.com" target="_blank">mickael.canevet@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Well, this is great, but unless I' wrong there is no way to manage the same file from multiple resources.<div>It looks like all augeas transformations must be done in the same augeas_file resource.</div><div><br></div><div>Would it be possible to use the existing augeas type to define the augeas transformations and use your code in an augeas_file resource that applies the transformations of all augeas resources in the catalog?</div></div><br></blockquote><div><br></div><div><br></div><div>This could indeed be the next step. It will probably be more complex, but I'd like to make augeas_file a kind of plugin on top of the augeas type and augesproviders. Something like:</div><div><br></div><div><br></div><div>augeas_file { '/etc/foo.conf':</div><div>  base => '/usr/share/doc/foo/examples/foo.conf',</div><div>}</div><div><br></div><div>augeas { 'foo bar':</div><div>  incl         => '/etc/foo.conf',</div><div>  lens        => 'Foo.lns',</div><div>  changes => 'set bar baz',</div><div>}</div><div><br></div><div>foo { 'baz':</div><div>  value => 'qux',</div><div>  target => '/etc/foo.conf',</div><div>}</div><div><br></div><div><br></div><div>Both the augeas and the foo (augeasprovider) resources would be collected/hijacked so as to be applied in memory by the augeas_file resource. It's obivously much more complex to implement than the current PoC though…</div><div><br></div><div><br></div><div>Raphaël</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="gmail_quote"><div><div class="h5"><div dir="ltr">Le mar. 28 juil. 2015 à 15:07, Raphaël Pinson <<a href="mailto:raphael.pinson@camptocamp.com" target="_blank">raphael.pinson@camptocamp.com</a>> a écrit :<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="h5"><div dir="ltr">I started a proof-of-concept implementation as <a href="https://github.com/raphink/puppet-augeas_file" target="_blank">https://github.com/raphink/puppet-augeas_file</a><div><br></div><div>Feedback welcome!</div></div><div dir="ltr"><div><br></div><div><br></div><div>Raphaël</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Jul 23, 2015 at 11:47 AM, Raphaël Pinson <span dir="ltr"><<a href="mailto:raphael.pinson@camptocamp.com" target="_blank">raphael.pinson@camptocamp.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span>On Fri, Jun 26, 2015 at 5:00 PM, Dominic Cleal <span dir="ltr"><<a href="mailto:dcleal@redhat.com" target="_blank">dcleal@redhat.com</a>></span> wrote:<br></span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span><span>On 26/06/15 15:38, Mickaël Canévet wrote:<br>
> Hello,<br>
><br>
> I'd like to be able to manage a file as a whole with puppet and augeas.<br>
> The typical use case is to take a sample file, or a systemd service<br>
> file, provided by a package as source and apply some augeas translations<br>
> on it, then write to a destination file.<br>
><br>
> I could use:<br>
><br>
> file { '/etc/foo/foo.conf':<br>
>   ensure => file,<br>
>   source => 'file:///usr/share/doc/foo/example/foo.conf',<br>
>   replace => false,<br>
> }<br>
> augeas { 'bar':<br>
>   context => '/files/etc/foo/foo.conf',<br>
>   changes => [ ... ],<br>
> }<br>
><br>
> But I don't like it because:<br>
> - If the sample file is updated (because of security reason for<br>
> example), my configuration file will not be updated,<br>
> - The configuration file is not managed as whole, and thus can be<br>
> manually corrupted.<br>
<br>
</span>Do you remember this function?<br>
<br>
</span><a href="https://github.com/camptocamp/puppet-augeas/blob/master/lib/puppet/parser/functions/augeas.rb" rel="noreferrer" target="_blank">https://github.com/camptocamp/puppet-augeas/blob/master/lib/puppet/parser/functions/augeas.rb</a><span><br>
<br>
It was written with the same ideas in mind - that you'd have some stock<br>
file, probably inside the module, copied from /usr/share/doc which would<br>
be transformed on the master by Augeas and put into the catalog.  That<br>
has the same disadvantage as the first, the file needs to be copied from<br>
the master.<br>
<span><br></span></span></blockquote><div><br></div><div><br></div><div>We did consider this function, for sure. However, it requires to store the file on the master side. The idea Mickaël and I have would be to use a template on the agent, not on the master.</div><div><br></div><div>This might be doable using aug_text_store and aug_text_retrieve, by:</div><div><br></div><div>* Shortcut: copying the file if target does not exist yet</div><div>* Reading the template file</div><div>* Inserting the template content into the tree with aug_text_store</div><div>* Applying changes to the tree</div><div>* Moving the resulting tree to the target file tree</div><div>* Saving</div><div><br></div><div><br></div><div>The problem is how to modelize that with resources? Obviously, the template parameter does not really go well with the augeas resource type or augeasproviders, as it would allow to specify a different template for entries in the same target…</div><div><br></div><div>One possibility we considered would be to add augeas transforms to the file resource type. Theses transforms would be applied to the resulting content of the file resource (whether using source or content), using aug_text_store/aug_text_retrieve.</div><div><br></div><div>Arguably, this could be done with two resources:</div><div><br></div><div>file { 'foo': replace => false } -> augeas { 'transform foo': }</div><div><br></div><div>The problem with that is that when the template changes, the file is not refreshed. And if we don't use replace => false, then it won't be idempotent…</div><div><br></div><div><br></div><div>Any thoughts on that?</div><span><font color="#888888"><div><br></div><div><br></div><div><br>-- <br><div><div dir="ltr"><div dir="ltr">Raphaël Pinson<div>Infrastructure Developer & Training Leader</div><div>+33 458 482 013<div><br></div><div>Camptocamp France<br>Savoie Technolac<br>BP 352<br>48, avenue du Lac du Bourget<br>73372 Le Bourget du Lac, Cedex<br><a href="http://www.camptocamp.com/" target="_blank">www.camptocamp.com</a></div></div></div></div></div></div></font></span></div>
</div></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr">Raphaël Pinson<div>Infrastructure Developer & Training Leader</div><div>+33 458 482 013<div><br></div><div>Camptocamp France<br>
Savoie Technolac<br>
BP 352<br>
48, avenue du Lac du Bourget<br>
73372 Le Bourget du Lac, Cedex<br>
<a href="http://www.camptocamp.com" target="_blank">www.camptocamp.com</a><br>
</div></div></div></div></div></div>
</div></div></div>
_______________________________________________<br>
augeas-devel mailing list<br>
<a href="mailto:augeas-devel@redhat.com" target="_blank">augeas-devel@redhat.com</a><br>
<a href="https://www.redhat.com/mailman/listinfo/augeas-devel" rel="noreferrer" target="_blank">https://www.redhat.com/mailman/listinfo/augeas-devel</a></blockquote></div>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr">Raphaël Pinson<div>Infrastructure Developer & Training Leader</div><div>+33 458 482 013<div><br></div><div>Camptocamp France<br>
Savoie Technolac<br>
BP 352<br>
48, avenue du Lac du Bourget<br>
73372 Le Bourget du Lac, Cedex<br>
<a href="http://www.camptocamp.com" target="_blank">www.camptocamp.com</a><br>
</div></div></div></div></div></div>
</div></div>