Forge Home


Patch files using diffs


19,288 latest version

4.3 quality score

Version information

  • 1.4.0 (latest)
  • 1.3.0
  • 1.2.2
  • 1.2.1
  • 1.2.0
  • 1.1.0
  • 1.0.2
  • 1.0.1
  • 1.0.0
released Oct 8th 2016
This version is compatible with:
  • Puppet Enterprise 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >=3.0.0 <5.0.0
  • ,

Start using this module

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

Add this module to your Puppetfile:

mod 'tohuwabohu-patch', '1.4.0'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add tohuwabohu-patch
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install tohuwabohu-patch --version 1.4.0

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.

Tags: patch, diff


tohuwabohu/patch — version 1.4.0 Oct 8th 2016


Puppet Forge Build Status


Manage and apply diff files on original files using the patch command.


  • Install patch with package settings; this itself doesn't do much. To apply patches, you have to use patch::file.
class { 'patch': }
  • Apply diff referenced by a file on a given original file
patch::file { '/path/to/file':
  diff_source => '/path/to/diff',
  • Apply inline diff on a given original file
patch::file { '/path/to/file':
  diff_content => '<inline-diff>',
  • Apply two diff files in a particular order on the same original file
$target = '/path/to/file'
patch::file { 'first-patch':
  target      => $target,
  prefix      => '0001',
  diff_source => '/path/to/0001.diff',
patch::file { 'second-patch':
  target      => $target,
  prefix      => '0002',
  diff_source => '/path/to/0002.diff',
  require     => Patch::File['first-patch'],
  • Apply diff to a directory
patch::directory { '/path/to/target/directory':
  diff_source => '/path/to/diff',
  strip => 2,


The module has been tested on the following operating systems. Testing and patches for other platforms are welcome.

  • Debian 7.0 (Wheezy)
  • Debian 8.0 (Jessie)
  • Ubuntu 14.04 (Trusty Tahr)
  • Ubuntu 16.04 (Xenial Xerus)


  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request


This project uses rspec-puppet and beaker to ensure the module works as expected and to prevent regressions.

gem install bundler
bundle install --path vendor

bundle exec rake spec
bundle exec rake beaker

(note: see Beaker - Supported ENV variables for a list of environment variables to control the default behaviour of Beaker)