Ask Your Question
1

collect method unknown (net_share)

asked 2014-11-19 08:36:40 -0500

astaldo gravatar image

I have a fresh install of puppet on debian 6.0 (squeeze) together with a windows agent. Im writing an own module and there are several steps that work nice.

Now I want to add the net_share module.

net_share{ "my_share":
  ensure      => present,
  path        => "$partition/my_share",
  permissions => ["${hostname}\\newuser,full"],
}

On my windows client i get this error message:

Error: Failed to apply catalog: Parameter permissions failed on Net_share[my_share]: Munging failed for value "MYSERVER\\newuser,full" in class permissions: undefined method `collect' for "MYSERVER\\newuser,full":String at /etc/puppet/environments/production/modules/my_module/manifests/init.pp:67
Wrapped exception:
Munging failed for value "MYSERVER\\newuser,full" in class permissions: undefined method `collect' for "MYSERVER\\newuser,full":String

I have no idea what I'm doing wrong and what I should do now. For testing purposes I looked into the modules content (net_share.rb)

  newproperty(:permissions, :parent => CaseInsensitiveProperty, :array_matching => :all) do
    desc "An array of permissions. Example: ['computer\\user,full', 'computer\\user2,change', 'computer\\user3,read']"

    munge do |value|
      value.collect do |item|
        user, access = item.split(',', 2)
        "#{user.strip},#{access.strip.downcase}"
      end
    end
  end

So i tried to execute this little ruby script

#!/usr/bin/env ruby

value = ["MYSERVER\newuser,full"]
value.collect do |item|
  user, access = item.split(',', 2)
  print "#{user.strip},#{access.strip.downcase}"
end

Which works (but doesn't give the right output) Anyway it "knows" the collect function.

So please can anyone help me with that? Im net to puppet and ruby.

edit retag flag offensive close merge delete

Comments

I am having same issue. Do we need to install another module or create a "collect" method? Any help will be appreciated. Thanks :)

Stako gravatar imageStako ( 2015-01-21 00:17:28 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-04-14 02:42:03 -0500

dima gravatar image

I think it's s because of changes from Ruby 1.8.x to 1.9.x on string handling...there's no more collect, strip or even each function because of unicode changes... I don't know if the below is the best way, but it works for me:

munge do |value|
  value.each_line do |item|
    user, access = item.split(',', 2)
    "#{user.lstrip.rstrip},#{access.lstrip.rstrip.downcase}"
  end
end
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-19 08:30:17 -0500

Seen: 351 times

Last updated: Nov 19 '14