Duplicate declartion error in rspec-puppet

asked 2016-05-05 06:32:55 -0600

Chutki gravatar image

Hi,

I have hadoop disk creation module below

define module_hadoop::iterate($fspace,$disk) {


  include 'module_hadoop::params'


  $apnd = inline_template('<%= fspace.to_i + 1 %>')


  if versioncmp("${apnd}", "${disk}") <= 0 {
    if versioncmp("${apnd}", '10') < 0 {


      file { "/dir/0${apnd}" :
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
      }


      filesystem { $::module_hadoop::params::pdisk[$apnd] :
        ensure  => present,
        fs_type => $::module_hadoop::params::fstype,
        options => $::module_hadoop::params::mkfs_options,
     }

      }
    }
    else {

         file { "/dir/${apnd}" :
        ensure => directory,
        owner  => 'root',
        group  => 'root',
        mode   => '0755',
      }


      filesystem { $::module_hadoop::params::pdisk[$apnd] :
        ensure  => present,
        fs_type => $::module_hadoop::params::fstype,
        options => $::module_hadoop::params::mkfs_options,
      }

    }

Below is the define rspec-puppet

describe 'module_hadoop::iterate', :type => 'define' do

  let(:pre_condition) { 'include module_hadoop::params' }
  let(:facts) {{ :operatingsystemrelease => '6' }}
  let(:title) { 'osversion' }
  let(:params) do
    {

     'fspace' => '0',
      'disk' => '10'
    }
  end 

  ['01',
   '02',
   '03',
   '04',
   '05',
   '06',
   '07',
   '08',
   '09',
   '010',].each do|value|

     it { should contain_file("/dir/#{value}").with(
        'ensure' => 'directory',
        'owner'  => 'root',
        'group'  => 'root',
        'mode'   => '0755',
      )}
  end
 end
end

I am getting below error when I rspec-puppet

Failure/Error: )}
     Puppet::Error:
       Duplicate declaration: Filesystem[undef] is already declared in file /root/modules/module_hadoop/spec/fixtures/modules/module_hadoop/manifests/iterate.pp:33; 
cannot redeclare at /root/modules/module_hadoop/spec/fixtures/modules/module_hadoop/manifests/iterate.pp:33 on node
edit retag flag offensive close merge delete

Comments

any update on this. still I couldn't find out the cause of the issue.

Chutki gravatar imageChutki ( 2016-05-06 05:49:03 -0600 )edit

Update showing the contents of the params class that is included. It's not obvious what's wrong.

Alex Harvey gravatar imageAlex Harvey ( 2016-05-07 11:20:28 -0600 )edit

so you mean to say the "params" manifests variable what we pass value to" filesystem" resource is having trouble.

Chutki gravatar imageChutki ( 2016-05-09 06:52:25 -0600 )edit

As I said. It's not obvious what's wrong. You have a duplicate resource somewhere, but not in the code sample you provided.

Alex Harvey gravatar imageAlex Harvey ( 2016-05-09 07:25:07 -0600 )edit