operatingsystemmajrelease unknown variable when running puppet-rspec test against selinux module.
Closed this issue · 4 comments
Affected Puppet, Ruby, OS and module versions/distributions
- Puppet: 5.3.3
- Ruby: 2.0.0p648
- Distribution: Centos 7.4.1708
- Module version: v1.5.2
How to reproduce (e.g Puppet code you use)
Using class in a manifest file in my own module as below:
class mymodule::control { notice ('Setting selinux enforced') class { 'selinux': mode => 'enforcing', type => 'targeted', } }
What are you seeing
Module works correctly when applied to a puppet slave, however the puppet-rspec tests fail due to an unknown variable ::operatingsystemmajrelease.
` Failure/Error: include mymodule::control
Puppet::PreformattedError:
Evaluation Error: Unknown variable: '::operatingsystemmajrelease'. at /etc/puppetlabs/code/modules/mymodule/spec/fixtures/modules/selinux/manifests/params.pp:18:6 on node puppet.eu-west-1.compute.internal
`
What behaviour did you expect instead
I expected the puppet-rspec test to pass.
Output log
Any additional information you'd like to impart
@mehstg if you want to test this yourself with your module and puppet-rspec you need to define this variable yourself.
we do it here: https://github.com/voxpupuli/puppet-selinux/blob/master/spec/default_module_facts.yml (voxpupuli specific I think). they get sourced here: https://github.com/voxpupuli/puppet-selinux/blob/master/spec/spec_helper.rb#L26-L27
Thanks very much for the example.
The example worked in my code, thanks very much. Unfortunately I immediately hit the next brick wall.
Evaluation Error: Unknown variable: '::selinux'. at etc/puppetlabs/code/modules/mymodule/spec/fixtures/modules/selinux/manifests/config.pp:42:33 on node puppet.eu-west-1.compute.internal
This appears to be in relation to the following line in config.pp
if ($mode == 'enforcing' and !$::selinux) {
@mehstg this is no discussion list here.
you can ask such questions on the puppet mailinglist (https://groups.google.com/forum/#!forum/puppet), IRC #puppet or #voxpupuli (webclient: https://webchat.freenode.net/) or the Slack puppet channels https://slack.puppet.com/