Skip to content

Instantly share code, notes, and snippets.

@DaffyDuke
Last active March 3, 2017 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaffyDuke/1721826bd90fc061ce8282a489d29b5c to your computer and use it in GitHub Desktop.
Save DaffyDuke/1721826bd90fc061ce8282a489d29b5c to your computer and use it in GitHub Desktop.

Here is a tip for those using the Puppet ‘augeas’ native resource: always use the ‘incl’ and the ‘lens’ parameters. Without that, Augeas will autoload all of the files defined in its lenses. On an empty VM that can take up to 1 second.

Here is my base test file:

$logrotate_file = '/etc/logrotate.d/httpd' 
augeas {
    'logrotate-httpd':
    context => "/files${logrotate_file}/rule/",     
    changes => [
        'set schedule daily',
        'set rotate 6',
        'set compress compress',     
    ], 
} 

It takes 0.91 seconds:

puppet apply test.pp

Notice: Compiled catalog for localhost in environment production in 0.14 seconds Notice: Finished catalog run in 0.91 seconds

If I specify the file and the lens:

$logrotate_file = '/etc/logrotate.d/httpd' 
augeas {  
    'logrotate-httpd':
    context => "/files${logrotate_file}/rule/",     
    incl    => $logrotate_file,     
    lens    => 'Logrotate.lns',     
    changes => [       
        'set schedule daily',       
        'set rotate 6',       
        'set compress compress',     
    ], 
} 

It takes 0.08 seconds:

puppet apply test.pp

Notice: Compiled catalog for localhost in environment production in 0.13 seconds Notice: Finished catalog run in 0.08 seconds

Note that this is linear. Augeas will load all its know files for each of the resources, so you will lose one second for each resource without these arguments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment