Ask Your Question
0

multiple array in def

asked 2014-11-13 06:47:23 -0600

Chutki gravatar image

Hi

I have two file

class hadoopfile::file {

  $diskname  = [aaa,bbb,ccc,ddd,eee,']

  $filename  = [02,03,04,05,06]

  hadoopfile::diskcreate_def { '$diskname:','$filename:' }
  #hadoopfile::diskcreate_def { $filename: }
}



define hadoopfile::diskcreate_def (
      $diskname,$filename = $title)
      {
      physical_volume {["/dev/$diskname"]:
        ensure  => present,
      }

      file { 'opt/db/$filename':
        ensure  => directory,
      }

      mount { filemount:
        ensure  => mounted,
        name    => "opt/db/$filename",
        fstype  => 'ext4',
        options => 'defaults',
        atboot  => true,
        dump    => '1',
        pass    => '2',
  require => File["/opt/hd/db/data/$filename"]
   }
  }

when I compile the above I got

`Syntax error at '}'; expected '}' at /etc/hadoopfile/manifests/file.pp:15 on node`

My doubt is, can we create pass two variable in define.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-04-03 21:03:36 -0600

updated 2015-04-04 09:09:21 -0600

Two arrays to a resource definition won't work.

class hadoopfile::file {
  $diskname  = [
    'aaa',
    'bbb',
    'ccc',
    'ddd',
    'eee',
  ]
  $filename = [
    '02',
    '03',
    '04',
    '05',
    '06',
  ]

  hadoopfile::diskcreate { $diskname: }
  hadoopfile::filecreate { $filename: }
}
define hadoopfile::diskcreate (
  $diskname = $title,
) {
  physical_volume { "/dev/${diskname}":
    ensure => present,
  }
}
define hadoopfile::filecreate (
  $filename = $title,
) {
  file { "/opt/hd/db/data/${filename}":
    ensure => directory,
  }

  mount { "filemount_${filename}":
    ensure  => mounted,
    name    => "opt/db/${filename}",
    fstype  => 'ext4',
    options => 'defaults',
    atboot  => true,
    dump    => '1',
    pass    => '2',
    require => File["/opt/hd/db/data/${filename}"]
  }
}
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2014-11-13 06:47:23 -0600

Seen: 168 times

Last updated: Apr 04 '15