Forge Home


Install a gpg-encrypted file onto a system, decrypting it locally on the system.


5,896 latest version

4.3 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.1.2 (latest)
  • 0.1.1
  • 0.1.0
released Dec 7th 2018
This version is compatible with:
  • Puppet Enterprise 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
  • Puppet >=2.7.0 <5.0.0

Start using this module

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

Add this module to your Puppetfile:

mod 'JohnsonEarls-gpgfile', '0.1.2'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add JohnsonEarls-gpgfile
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install JohnsonEarls-gpgfile --version 0.1.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.



JohnsonEarls/gpgfile — version 0.1.2 Dec 7th 2018


Puppet Forge Build Status

Table of Contents

  1. Description
  2. Setup - The basics of getting started with gpgfile
  3. Usage - Configuration options and additional functionality
  4. Reference - An under-the-hood peek at what the module is doing and how
  5. Limitations - OS compatibility, etc.
  6. Development - Guide for contributing to the module


gpgfile is an attempt at a file replacement that supports gpg-encrypted files.

Because of security concerns, some organizations don't want encrypted data to be decrypted on the puppet master (whether due to protection of the secret key or concerns that decrypted data might appear in the catalog, and thus in cached files on the puppet server and host). Every other encrypted data solution I've found for Puppet involves having the puppet master do the decryption from encrypted Hiera keys. This module attempts to provide an alternative solution, doing the decryption on the agent itself.


Setup Requirements

This module will not manage gpg keys. It's assumed that your gpg secret keyring is already prepared.

Beginning with gpgfile

gpgfile { '/etc/secret/passwordfile':
  ensure           => decrypted ,
  owner            => root ,
  group            => root ,
  mode             => '0600' ,
  encrypted_suffix => '.asc' ,
  source           => "puppet:///${module_name}/passwordfile.gpg" ,
  gpg_keyring      => 'secring.gpg' ,


gpgfile transfers a single encrypted file to the host and locally decrypts it using gpg. The file will be decrypted as the final owner, but can be decrypted using any gpg secret keyring to which that user has access. The encrypted file is preserved, so that the agent can determine if it's changed or not, rather than attempting to decrypt every time. The encrypted file can be saved into the same directory as the target file or into any specified directory, and it can be named after the target file (with a suffix, .gpg by default) or can be given an arbitrary name.





All parameters are optional, unless otherwise noted.

  • ensure: Ensures whether the resource is present. Valid options: decrypted, encrypted, absent, or present (which is the same as decrypted). Defaults to decrypted.
  • content: The encrypted file contents. Either source or content must be specified.
  • encrypted_dir: The directory in which to store the encrypted file. Defaults to the same directory as the decrypted file.
  • encrypted_mode The permissions to use for the encrypted file. Defaults to the same permissions as the decrypted file.
  • encrypted_name The filename to use when storing the encrypted file. Defaults to undefined. If provided, overrides the encrypted_suffix.
  • encrypted_suffix The suffix to append to the decrypted filename when storing the encrypted file. Defaults to .gpg.
  • group The group that owns both the decrypted and encrypted files. Defaults to root.
  • keyring The gpg keyring to use for decryption. Must be accessible by owner. If it begins with ~, it will be relative to owner's home directory. If this is a bare file, it will be located in ~/.gnupg. Defaults to secring.gpg.
  • mode The permission of the decrypted file. Must be an octal mode for this type. Defaults to 0600. A warning will be generated if any permissions are granted to other (i.e. the last octal digit is anything other than 0)
  • owner The owner of both the decrypted and encrypted files. Defaults to root.
  • source The source of the encrypted file. Either source or content must be specified.


Only tested on RedHat 5.x and 6.x systems.