Lately I've been submitting a few tweaks and watching changes to Puppet's Augeas provider closely, so I thought I'd write up a summary of recent modifications and those that might be coming.
#6494:
New commands, defvar, defnode, mv and setm
Available from Puppet 2.7.0
Some new commands were added to the provider that are available in newer versions of Augeas and ruby-augeas. These follow exactly the same syntax as augtool uses (so see its help for more info):
- defvar/defnode create variables to save typing. Needs Augeas 0.5.0 and ruby-augeas 0.3.0 or higher.
- mv for moving a node and its children around the tree. Needs Augeas 0.3.0 and ruby-augeas 0.2.0 or higher.
- setm for setting the value of multiple nodes at once (like a loop). Needs Augeas 0.7.2 and ruby-augeas 0.4.0 or higher.
#2728:
File diffs and 50% speed increase
Available from Puppet 2.7.3
Mike Knox tackled a long-standing feature request to give file diffs when
Augeas resources are applied, in the same way as normal File resoures. When
running Puppet with --test
or --show_diff
, you'll now
see a diff printed for the modified file.
Due to the implementation, this allowed Mike to make a great optimisation, halving the time it takes to apply an Augeas resource. The previous implementation followed Puppet's usual pattern of checking if the resource was in sync (i.e. changes had to be applied) before executing those changes. The change now means the provider only makes the change once during the test phase and no longer loads Augeas again when making the change to the live filesystem.
(A bugfix will be included in 2.7.4 for resources that fail to save).
#7854:
Augeas version fact
Available from Facter 1.6.1
A new fact will contain the version number of the underlying Augeas library as
$augeasversion
. This is just the version of the library (from
/augeas/version
) and not ruby-augeas or the lenses
necessarily.
#5606:
Error messages shown in Puppet debug mode
Available from Puppet 2.8.0 (Telly)
When Augeas changes cannot be saved, the provider unhelpfully reports
Save failed with return code false
to say that
aug_save
failed. This usually indicates the changes made to the
tree can't be written back to the file as they don't map to the lens'
data structure.
Augeas provides some details about where in the lens the disagreement
occurred under /augeas//error
, so this information is now printed
to the debug log (run puppet agent -t --debug
) instead of having
to reproduce the error by hand with augtool.
#7285:
Optimise file loading using context information
Available from Puppet 2.8.0 (Telly)
Starting up Augeas with all ~90 lenses over 100-200 files normally takes a
second or two, which quickly adds up when applying a large catalog containing many
Augeas resources. Using the context
attribute if it's given, this
patch optimises loading to only include the file given by the resource
context.
It uses the glob()
path function added in Augeas 0.9.0 to find
/augeas/load//incl
nodes (which contain globs) that match the
context, then deletes all other incl nodes. Next it calls
aug_load
, resulting in a much quicker load time.
Use aug_srun to evaluate commands
In development
Augeas 0.9.0 exposed the command parsing from augtool as a separate API
function, aug_srun
.
Currently the provider parses all commands itself, adding in the context where
needed and then calling the appropriate aug_*
method from the
ruby-augeas API. It simulates exactly what augtool (and aug_srun)
would do to try and give fully compatible command processing.
Instead we could use aug_srun for command parsing, making a much smaller Augeas provider. This would also help us get new commands that are added to Augeas as soon as they're available, without users having to wait for updates to Augeas, ruby-augeas and finally Puppet.
It also would help us look at improving the commands available - perhaps
there are changes that could be made so it's easier to create fully idempotent
Augeas resources from within Puppet (without onlyif
clauses).