Error: Could not retrieve local facts: undefined method `split' for [1, 2, 3, 4, 5]:Array

133 views
Skip to first unread message

Supriya Uppalapati

unread,
Oct 10, 2014, 1:41:41 PM10/10/14
to puppe...@googlegroups.com
Hi,

when i am trying to do puppet custom facts to split [1,2,3,4,5] to 
1
2
3
4
5

It is throwing me error:
Error: Could not retrieve local facts: undefined method `split' for [1, 2, 3, 4, 5]:Array


Here is my facts

require 'facter'

ary = [1,2,3,4,5]
ary.map { |i| "'" + i.to_s + "'"}.join(",")

#str = ""
ary.each do |i|
#id,val = row[i]
 val = ary.split ","
Facter.add("base") do
  setcode do
    i
end
end
end


Anyone, please  help me

Adrien Thebo

unread,
Oct 10, 2014, 3:15:15 PM10/10/14
to puppe...@googlegroups.com
Hi Supriya,

If you want an array of items printed as a newline separated list of values, then you probably want to use the 'join' method (http://www.ruby-doc.org/core-2.1.3/Array.html#method-i-join) to join the array on newlines instead of split.

This question looks like it's asking for general code help, rather than asking specific questions about developing on Facter, Puppet, Hiera, or another one of our open source projects. Please note that puppet-dev is not an appropriate place to ask general coding questions. You'll have better luck trying the Ruby users forum (https://www.ruby-forum.com/forum/ruby), puppet-users mailing list (https://groups.google.com/forum/#!forum/puppet-users) or the #puppet IRC channel. If you need more in depth help there are projects like Hack Hands (https://hackhands.com/) that can provide close mentoring. If you need specialized help for Puppet then a Professional Services engagement (http://puppetlabs.com/services/professional-services) might be your best bet.



--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-dev+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-dev/910ad676-77c4-43d1-8a95-42e398ab249d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Adrien Thebo | Puppet Labs
Reply all
Reply to author
Forward
0 new messages