Ask Your Question

split function not accept by puppet

asked 2016-06-01 03:49:31 -0500

Chutki gravatar image


I got below error when I rspec-puppet

 /opt/puppetlabs/puppet/bin/bundle exec rake spec

           Evaluation Error: Error while evaluating a Function Call, 'split' parameter 'str' expects a String value, got Undef at /root/modules_new/module_name/spec/fixtures/modules/module_name/manifests/params.pp:29:17 on node.

when I open the code it contain.

class module_name::params{

$tmp1      = split($::blockdevices, ',')
 $tmp2      = grep($tmp1, 'sd')
$count     =count(tmp2)

The code take the node disk count.

below is my gem list

/opt/puppetlabs/puppet/bin/gem list

bigdecimal (1.2.4)
bundle (0.0.1)
bundler (1.12.5)
hiera (3.0.5)
puppet (4.3.1)
puppet_forge (2.1.1)
r10k (2.1.1)
rake (10.1.0)
rdoc (4.1.0)
rest-client (1.6.9)
rugged (0.21.4)
semantic_puppet (0.1.0)
stomp (1.3.3)
test-unit (
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2016-06-01 10:55:59 -0500

cosman2001 gravatar image

Looks like the fact $::blockdevices is undefined causing split to throw an error. Since you are using rspec you need to explicitly define every fact you use.

See the following for an example of defining facts in a spec file:

Also you can try this out on the Puppet REPL if you just want to test the function.

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


Asked: 2016-06-01 03:49:31 -0500

Seen: 132 times

Last updated: Jun 01 '16