Commit graph

6 commits

Author SHA1 Message Date
Hunter Haugen
52bc6f8dfc Remove inifile class, test, and dependency
PR #156 merged a base class called `inifile` that dynamically queried
hiera using explicit `hiera_hash()` functions and required functions
from stdlib.

It is an anti-pattern for component classes to contain hiera
functions (even ones that do not trigger under all circumstances) as
this leads to tight-coupling with hiera data structures. It also
promotes the anti-pattern of declaring resources directly in hiera.

Also, inifile is not going to receive a major version increase for a
while (we hope) and so adding a dependency is not desirable at this
point.

Unfortunately this feedback was missed while reviewing the original PR,
so it has to be reverted.
2016-03-07 11:33:32 -08:00
Dominic Cleal
b425fe5a49 Remove brackets from ini_setting titles to workaround PUP-4709
Puppet 4.0 and 4.1 are affected by PUP-4709 which raises duplicate
resource errors when using create_ini_settings(), due to the inclusion
of square brackets in the resource titles.

    Error while evaluating a Function Call, Duplicate
    declaration: Ini_setting[[foo] bar] is already declared; cannot
    redeclare

Removing these from the function allows it to work on these Puppet
versions without error.
2016-02-09 08:06:57 +00:00
Garrett Honeycutt
d83f3011f9 Add ability to specify a hash of ini_settings and ini_subsettings.
This added functionality allows you to specify hashes for ini_setting
and ini_subsetting so that they might be stored in Hiera. Without this
patch, you need to use ini_setting and ini_subsetting resources strictly
in code whereas with this patch, you could describe this in Hiera.
2016-01-06 12:27:21 -05:00
David Danzilio
a94f51e68d Adding path to create_ini_settings resources
Currently the create_ini_settings function creates an ini_setting with a
title comprised of the section and setting names. This means that we
run into resource conflicts when defining the same section/setting
combinations but in different files. Since the path parameter is
required, we can safely add this to the title of the ini_setting
resource created by the create_ini_settings function. This commit does
just that.
2015-08-12 18:00:57 -04:00
mh
6eb8f9ca98 introduce create_ini_settings
create_ini_settings is a function that allows you to create
ini_setting resources from a simple hash:

    $settings = {  section1 => {
        setting1 => val1
      },
      section2 => {
        setting2 => val2,
        setting3 => {
          ensure => absent
        }
      }
    }
    $defaults = {
      path => '/tmp/foo.ini'
    }
    create_ini_settings($settings,$defaults)

Will create the following resources

    ini_setting{'[section1] setting1':
      ensure  => present,
      section => 'section1',
      setting => 'setting1',
      value   => 'val1',
      path    => '/tmp/foo.ini',
    }
    ini_setting{'[section2] setting2':
      ensure  => present,
      section => 'section2',
      setting => 'setting2',
      value   => 'val2',
      path    => '/tmp/foo.ini',
    }
    ini_setting{'[section2] setting3':
      ensure  => absent,
      section => 'section2',
      setting => 'setting3',
      path    => '/tmp/foo.ini',
    }

This allows one to create much easier classes
that should be able to manage an arbritary set of
ini-style settings without having to specify each
one of them.
2015-01-28 22:09:34 +01:00
Richard Clamp
bd6d244610 add a type to test inheriting from ini_setting
In order to test with rspec-puppet we need to set up the fixtures, and test via
rake spec, so we change that too
2013-07-16 10:17:27 +01:00