diff --git a/.fixtures.yml b/.fixtures.yml index db98538..61abbcb 100644 --- a/.fixtures.yml +++ b/.fixtures.yml @@ -1,3 +1,4 @@ fixtures: symlinks: inifile: "#{source_dir}" + create_multiple_ini_settings: "#{source_dir}/spec/fixtures/create_multiple_ini_settings" diff --git a/.gitignore b/.gitignore index dd126f2..0cd25de 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ pkg/ Gemfile.lock vendor/ -spec/fixtures/ +spec/fixtures/manifests/ +spec/fixtures/modules/ .vagrant/ .bundle/ coverage/ diff --git a/README.markdown b/README.markdown index 80fba7b..627e422 100644 --- a/README.markdown +++ b/README.markdown @@ -449,6 +449,8 @@ Default value: '{}'. This module has been tested on [all PE-supported platforms](https://forge.puppetlabs.com/supported#compat-matrix), and no issues have been identified. Additionally, it is tested (but not supported) on Windows 7, Mac OS X 10.9, and Solaris 12. +Due to (PUP-4709) the create_ini_settings function will cause errors when attempting to create multiple ini_settings in one go when using Puppet 4.0.x or 4.1.x. If needed, the temporary fix for this can be found here: https://github.com/puppetlabs/puppetlabs-inifile/pull/196. + ##Development Puppet Labs modules on the Puppet Forge are open projects, and community contributions are essential for keeping them great. We can't access the huge number of platforms and myriad of hardware, software, and deployment configurations that Puppet is intended to serve. diff --git a/lib/puppet/parser/functions/create_ini_settings.rb b/lib/puppet/parser/functions/create_ini_settings.rb index eb00404..f0eff6d 100644 --- a/lib/puppet/parser/functions/create_ini_settings.rb +++ b/lib/puppet/parser/functions/create_ini_settings.rb @@ -69,7 +69,7 @@ EOS end settings[section].each do |setting, value| - res["#{path} #{section} #{setting}"] = { + res["#{path} [#{section}] #{setting}"] = { 'ensure' => 'present', 'section' => section, 'setting' => setting, diff --git a/spec/classes/create_ini_settings_test_spec.rb b/spec/classes/create_ini_settings_test_spec.rb index e1c99fe..c81f93f 100644 --- a/spec/classes/create_ini_settings_test_spec.rb +++ b/spec/classes/create_ini_settings_test_spec.rb @@ -2,21 +2,21 @@ require 'spec_helper' # end-to-end test of the create_init_settings function describe 'create_ini_settings_test' do it { should have_ini_setting_resource_count(3) } - it { should contain_ini_setting('/tmp/foo.ini section1 setting1').with( + it { should contain_ini_setting('/tmp/foo.ini [section1] setting1').with( :ensure => 'present', :section => 'section1', :setting => 'setting1', :value => 'val1', :path => '/tmp/foo.ini' )} - it { should contain_ini_setting('/tmp/foo.ini section2 setting2').with( + it { should contain_ini_setting('/tmp/foo.ini [section2] setting2').with( :ensure => 'present', :section => 'section2', :setting => 'setting2', :value => 'val2', :path => '/tmp/foo.ini' )} - it { should contain_ini_setting('/tmp/foo.ini section2 setting3').with( + it { should contain_ini_setting('/tmp/foo.ini [section2] setting3').with( :ensure => 'absent', :section => 'section2', :setting => 'setting3', diff --git a/spec/classes/create_multiple_ini_settings_spec.rb b/spec/classes/create_multiple_ini_settings_spec.rb new file mode 100644 index 0000000..374557e --- /dev/null +++ b/spec/classes/create_multiple_ini_settings_spec.rb @@ -0,0 +1,5 @@ +require 'spec_helper' + +describe 'create_multiple_ini_settings' do + it { is_expected.to compile } +end diff --git a/spec/fixtures/create_multiple_ini_settings/manifests/init.pp b/spec/fixtures/create_multiple_ini_settings/manifests/init.pp new file mode 100644 index 0000000..b4595a9 --- /dev/null +++ b/spec/fixtures/create_multiple_ini_settings/manifests/init.pp @@ -0,0 +1,15 @@ +class create_multiple_ini_settings { + +$defaults = { 'path' => '/tmp/foo.ini' } +$example = { + 'section1' => { + 'setting1' => 'value1', + 'settings2' => { + 'ensure' => 'absent' + } + } +} +create_ini_settings($example, $defaults) + +} +