Ask Your Question
1

passing string of ip's and want to access each ip at a time

asked 2013-03-29 12:55:51 -0600

redmine gravatar image

updated 2013-03-29 15:22:36 -0600

llowder gravatar image

I am passing array of IP address in puppet manifest like this ips = ["1.2.3.4","5.6.7.8","5.7.9.1"] and want do some operation on each IP address in my type function.

I am getting this error:

Error: Parameter property failed[network/dns/client]: can't convert String into Integer

Then I tried to convert my string to array by value.split(",") but got:

value.class is array

and

value is [1.2.3.45.6.7.85.7.9.1].

My goal is to get access to each IP address separately and do ... (more)

edit retag flag offensive close merge delete

Comments

Does is_array($ips) pass?

Ancillas gravatar imageAncillas ( 2013-03-29 17:08:16 -0600 )edit
1

Are speaking of the Puppet Ruby DSL or about a custom type/provider? If it is the latter can you please provide the whole method (the newparam block or the ...(more)

Stefan gravatar imageStefan ( 2013-03-30 09:11:33 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
1

answered 2013-04-26 11:18:23 -0600

xtraclass gravatar image
ips.each do |ipstring|
     value = ipstring
     # value must be of type string, and not int
end

This is at least some Ruby code. I don't know where you need it exactly, but maybe it is a hint...

edit flag offensive delete link more
0

answered 2013-04-26 14:25:12 -0600

A defined type accepts an array as its title (namevar):

if is_array($ips) {
  internal { $ips: other => options, as => well }
}
define internal ($ip = $title) {
  do_something_with($ip)
}

Hence if it's possible in your scenario you could define an internal type and pass the array there. It all depends on what you want to do.

Puppet stdlib has a join() function that can be used to convert it to a string.

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

Stats

Asked: 2013-03-29 12:55:51 -0600

Seen: 376 times

Last updated: Apr 26 '13