Forge Home


Puppet Augeas_file module


6,959 latest version

3.1 quality score

We run a couple of automated
scans to help you access a
module's quality. Each module is
given a score based on how well
the author has formatted their
code and documentation and
modules are also checked for
malware using VirusTotal.

Please note, the information below
is for guidance only and neither of
these methods should be considered
an endorsement by Puppet.

Version information

  • 0.3.2 (latest)
  • 0.3.1
  • 0.3.0
  • 0.2.0
  • 0.1.0
released Jun 20th 2016
This version is compatible with:
  • Puppet Enterprise 3.x
  • Puppet 3.x
  • ,

Start using this module

  • r10k or Code Manager
  • Bolt
  • Manual installation
  • Direct download

Add this module to your Puppetfile:

mod 'camptocamp-augeas_file', '0.3.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add camptocamp-augeas_file
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install camptocamp-augeas_file --version 0.3.2

Direct download is not typically how you would use a Puppet module to manage your infrastructure, but you may want to download the module in order to inspect the code.



camptocamp/augeas_file — version 0.3.2 Jun 20th 2016

Augeas_file resource type

Puppet Forge Version Puppet Forge Downloads Build Status

What is this?

There are two main approaches when managing a file from Puppet:

  • Manage the file in parts:

    • native resource (host, mailalias, augeasproviders resource types, etc.)
    • concat resource
    • augeas resource
    • file_line resource
  • Manage the file in its entirety:

    • file resource with content (template, variables)
    • file resource with source (using fileserver or local file)
    • native resources with purging

One case that is not possible with these is to:

  • use a local file as a template
  • modify it to create a target file

The augeas_file type allows to do that. It typically allows to use an example configuration file provided by a system package and tune it to create a configuration file, idempotently.


  • Augeas >= 1.0.0
  • ruby-augeas >= 0.5.0



You can use augeas_file to manage a file entirely with one resource, listing Augeas changes in the changes parameter:

# augeas_file doesn't manage file rights
# use the file resource type for that
file { '/etc/apt/sources.list.d/jessie.list':
  ensure => file,
  owner  => 'root',
  group  => 'root',
augeas_file { '/etc/apt/sources.list.d/jessie.list':
  lens    => 'Aptsources.lns',
  base    => '/usr/share/doc/apt/examples/sources.list',
  changes => ['setm ./*[distribution] distribution jessie'],

You might want to wrap this in a defined resource type:

define apache::userdir (
) {
  file { $title:
    ensure => file,
    owner  => 'www-data',
    group  => 'root',
  augeas_file { $title:
    base    => '/usr/share/doc/apache2.2-common/examples/apache2/extra/httpd-userdir.conf',
    lens    => 'Httpd.lns',
    changes => [
      "set Directory/arg '\"${directory}\"'",
      'rm Directory/directive/arg[.="Indexes"]',

apache::userdir { '/var/www/blog/conf/userdir.conf':
  directory => '/var/www/blog/htdocs',

Triggering augeas resources

The augeas_file has the possibility of working with other augeas resources whose incl parameter matches their name:

file { '/var/www/blog/conf/userdir.conf':
  ensure => file,
  owner  => 'www-data',
  group  => 'root',
  mode   => '2570',

augeas_file { '/var/www/blog/conf/userdir.conf':
  base => '/usr/share/doc/apache2.2-common/examples/apache2/extra/httpd-userdir.conf',

augeas { 'userdir directory':
  incl    => '/var/www/blog/conf/userdir.conf',
  lens    => 'Httpd.lns',
  changes => 'set Directory/arg "\"/var/www/blog/htdocs\""',

augeas { 'userdir no indexes':
  incl    => '/var/www/blog/conf/userdir.conf',
  lens    => 'Httpd.lns',
  changes => 'rm Directory/directive/arg[.="Indexes"]',

This allows to split the changes into individual resources.