Forge Home

exfile

Extended file resource

9,771 downloads

7,480 latest version

4.4 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

  • 1.0.9 (latest)
  • 1.0.1
released May 21st 2016
This version is compatible with:
  • , , , , , , , , ,

Start using this module

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

Add this module to your Puppetfile:

mod 'vicinus-exfile', '1.0.9'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add vicinus-exfile
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install vicinus-exfile --version 1.0.9

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
Tags: file

Documentation

vicinus/exfile — version 1.0.9 May 21st 2016

#exfile

##Overview

The exfile module defines an extended file resource which supports filenames which are relative to a base directory. Also parent directories can be automatically created (with some limitations). Content can be created via templates and path and target parameters can contain special variables, that are expanded during resource creation.

##Examples

The exfile resource can be used like the file resource. To define a file relative to configured base directory, use the basedir parameter.

    exfile { 'test.txt':
      basedir => '/tmp',
    }

This will create the file /tmp/test.txt. It's also possible to create with the path parameter. The following will also create /tmp/test.txt.

    exfile { 'testfile':
      path    => 'test.txt',
      basedir => '/tmp',
    }

###create_parent_dirs examples

create_parent_dirs ensures, that file resources with ensure directory for every directory between basedir (or '/' if basedir is not set) and the location of the exfile are created.

    exfile { 'a/b/1.txt':
      basedir => '/tmp',
      create_parent_dirs => true,
    }
    exfile { 'a/b/2.txt':
      basedir => '/tmp',
      create_parent_dirs => true,
    }

The example above will create file resources for the directories /tmp/a and /tmp/b but not for /tmp. The parameters owner, group and mode if set at the exfile resource are also used for the directory file resources. Puppet will automatically add the x modifier to the mode parameter of directories. ensure_resource is used, so that not multiple file resources for the same directory are created. Therefore the limitations of ensure_resource apply (all parameters must be identical). Also an error applying the created catalog will ocour, if some directory in the list of automatically created directories is actually a link to another directory.

###content_type examples

The content_type can be used to format the provided content.

    exfile { '/tmp/test.txt':
      content_type => 'erb',
      content_template => 'exfile/hashofkeyvalue.erb',
      content => { 'key1' => 'value1', 'key2' => 'value2', },
    }

The above example will create a file with content

  key1 = value1
  key2 = value2