Forge Home

filemagic

Edit files the easy way using Puppet - like magic

13,517 downloads

6,888 latest version

3.8 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.6.1 (latest)
  • 0.6.0
  • 0.5.2
  • 0.5.1
  • 0.5.0
  • 0.4.1
  • 0.4.0
  • 0.3.0
  • 0.2.0
  • 0.1.0
released Aug 28th 2018

Start using this module

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

Add this module to your Puppetfile:

mod 'geoffwilliams-filemagic', '0.6.1'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add geoffwilliams-filemagic
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install geoffwilliams-filemagic --version 0.6.1

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

geoffwilliams/filemagic — version 0.6.1 Aug 28th 2018

Build Status

filemagic

Table of Contents

  1. Description
  2. Setup - The basics of getting started with filemagic
  3. Usage - Configuration options and additional functionality
  4. Limitations - OS compatibility, etc.
  5. Development - Guide for contributing to the module

Description

Do you like files? Do you like magic? If so, this is the module for you! Puppet is a great language but out-of-the-box it expects and demands that you do things The Puppet Way which isn't always possible.

Take for example the following situations:

  • Your maintaining a fleet of brownfield production machines with an unknown state
  • You must follow your installation orders and they say to edit, not replace files
  • Files shared between multiple 'owners' e.g., modules, people, programs, etc
  • You don't want to fully template a file in order to receive upstream fixes
  • You need to do really simple edit(s)!

Features

Planned

  • Make a file 'sandwich' (insert data into a point inside the file)
  • Un-make a file 'sandwich'
  • Delete
  • Comment (not *ML)

Implemented

fm_append

  • Append data to a file
  • Un-append data to a file
  • Specify match_start - The first line of input to append from, for cases where some data already exists

fm_gsub

  • Replace a regular expression
  • Delete a regular expression

fm_prepend

  • Prepend data to a file
  • Un-prepend data to a file
  • Specify match_end - The last line of input to prepend to, for cases where some data already exists

fm_replace

  • Find and replace lines of data in a file
  • Un-replace (delete) matching lines
  • Matches all instances of the match regexp and replaces/deletes as requested

Setup

  • There is no setup and FileMagic is cross platform! Please create an issue if you find this not to be the case.

Usage

See reference and examples

Limitations

  • Not supported by Puppet, Inc.
  • Not intended for use with 'large' files - entire file to be edited is presently read into memory

Development

PRs accepted :)

Testing

This module supports testing using PDQTest.

Test can be executed with:

bundle install
make

See .travis.yml for a working CI example