Ask Your Question

rspec-puppet doesn't support floor function

asked 2015-11-12 03:45:20 -0500

Chutki gravatar image

updated 2015-11-12 03:46:49 -0500


I wrote rspec-puppet test case for below manifests

file { '/etc/sysctl.conf':
    ensure => present
 $shmmni = floor($::memorysize_mb / 4)
 sysctl { 'kernel.shmmni':
    ensure    => present,
    permanent => 'yes',
    value     => $shmmni

rspec-puppet sysctl_spec.rb

require 'spec_helper'

describe 'sysctl', :type => 'class' do

  it { should contain_file('/etc/sysctl.conf').with(
    :ensure => 'present'

when I run /opt/puppet/bin/rake rspec getting below error

 Failure/Error: )}
       Unknown function floor at /etc/puppetlabs/puppet/modules/mod_name/spec/fixtures/modules/mod_name/manifests/sysctl.pp:6 on node

below is my .fixtures.yml file

    mod_name: "#{source_dir}"
    stdlib: "/etc/puppetlabs/puppet/modules/crp/stdlib"
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2015-11-12 04:07:20 -0500

Cristian Falcas gravatar image

Try this .fixtures.yml:

    stdlib: 'git://'
    "your_module_name": "#{source_dir}"
edit flag offensive delete link more


I already downloaded stdlib module in my server, also I tried "stdlib: "/etc/puppetlabs/puppet/modules/crp/stdlib" for other modules file_line function and it worked

Chutki gravatar imageChutki ( 2015-11-12 10:27:17 -0500 )edit

You get the same error with the fixes from the fixtures file?

Cristian Falcas gravatar imageCristian Falcas ( 2015-11-12 11:19:37 -0500 )edit

yes I got same error only for floor function.

Chutki gravatar imageChutki ( 2015-11-12 23:01:42 -0500 )edit

the floor function worked after :/opt/puppet/bin/rake spec" but I am getting " Failure/Error: )} Puppet::Error: left operand of / is not a number at /etc/puppetlabs/puppet/modules/my_mod/spec/fixtures/modules/my_mod/manifests/sysctl.pp:6 on node rspec doesn't support special character

Chutki gravatar imageChutki ( 2015-11-13 10:47:20 -0500 )edit

Can you tell us the content of /etc/puppetlabs/puppet/modules/my_mod/spec/fixtures/modules/my_mod/manifests/sysctl.pp?

Cristian Falcas gravatar imageCristian Falcas ( 2015-11-15 12:33:28 -0500 )edit

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: 2015-11-12 03:45:20 -0500

Seen: 703 times

Last updated: Nov 12 '15