Forge Home


Resource types for managing settings in INI files


24,370 latest version

4.1 quality score

Version information

  • 0.10.4 (latest)
  • 0.10.3
  • 0.10.2
  • 0.10.1
  • 0.10.0
  • 0.9.0
  • 0.0.3
  • 0.0.2
  • 0.0.1
released Jul 24th 2013

Start using this module

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

Add this module to your Puppetfile:

mod 'cprice404-inifile', '0.10.4'
Learn more about managing modules with a Puppetfile

Add this module to your Bolt project:

bolt module add cprice404-inifile
Learn more about using this module with an existing project

Manually install this module globally with Puppet module tool:

puppet module install cprice404-inifile --version 0.10.4

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: files, settings, ini


cprice404/inifile — version 0.10.4 Jul 24th 2013

Build Status

NOTE: this module has been moved to the Puppet Labs namespace.

INI-file module

This module provides resource types for use in managing INI-style configuration files. The main resource type is ini_setting, which is used to manage an individual setting in an INI file. Here's an example usage:

ini_setting { "sample setting":
  path    => '/tmp/foo.ini',
  section => 'foo',
  setting => 'foosetting',
  value   => 'FOO!',
  ensure  => present,

A supplementary resource type is ini_subsetting, which is used to manage settings that consist of several arguments such as

JAVA_ARGS="-Xmx192m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/pe-puppetdb/puppetdb-oom.hprof "

ini_subsetting {'sample subsetting':
  ensure  => present,
  section => '',
  key_val_separator => '=',
  path => '/etc/default/pe-puppetdb',
  setting => 'JAVA_ARGS',
  subsetting => '-Xmx',
  value   => '512m',

implementing child providers:

The ini_setting class can be overridden by child providers in order to implement the management of ini settings for a specific configuration file.

In order to implement this, you will need to specify your own Type (as shown below). This type needs to implement a namevar (name), and a property called value:


Puppet::Type.newtype(:glance_api_config) do
  newparam(:name, :namevar => true) do
    desc 'Section/setting name to manage from glance-api.conf'
    # namevar should be of the form section/setting
  newproperty(:value) do
    desc 'The value of the setting to be defined.'
    munge do |v|

This type also must have a provider that utilizes the ini_setting provider as its parent:


# my_module/lib/puppet/provider/glance_api_config/ini_setting.rb
  # set ini_setting as the parent provider
  :parent => Puppet::Type.type(:ini_setting).provider(:ruby)
) do
  # implement section as the first part of the namevar
  def section
    resource[:name].split('/', 2).first
  def setting
    # implement setting as the second part of the namevar
    resource[:name].split('/', 2).last
  # hard code the file path (this allows purging)
  def self.file_path

Now, the individual settings of the /etc/glance/glance-api.conf file can be managed as individual resources:

glance_api_config { 'HEADER/important_config':
  value => 'secret_value',

Provided that self.file_path has been implemented, you can purge with the following puppet syntax:

resources { 'glance_api_config'
  purge => true,

If the above code is added, then the resulting configured file will only contain lines implemented as Puppet resources

A few noteworthy features:

  • The module tries hard not to manipulate your file any more than it needs to. In most cases, it should leave the original whitespace, comments, ordering, etc. perfectly intact.
  • Supports comments starting with either '#' or ';'.
  • Will add missing sections if they don't exist.
  • Supports a "global" section (settings that go at the beginning of the file, before any named sections) by specifying a section name of "".