Forge Home

augeas_file

Puppet Augeas_file module

11,580 downloads

7,618 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.

Support the Puppet Community by contributing to this module

You are welcome to contribute to this module by suggesting new features, currency updates, or fixes. Every contribution is valuable to help ensure that the module remains compatible with the latest Puppet versions and continues to meet community needs. Complete the following steps:

  1. Review the module’s contribution guidelines and any licenses. Ensure that your planned contribution aligns with the author’s standards and any legal requirements.
  2. Fork the repository on GitHub, make changes on a branch of your fork, and submit a pull request. The pull request must clearly document your proposed change.

For questions about updating the module, contact the module’s author.

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.

Download

Documentation

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.

Requirements

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

Usage

Standalone

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 (
  $directory,
) {
  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.