puppet-splunk
puppet-splunk copied to clipboard
Warning unknown variable 'staged_package' when `yum` is used as package provider
Affected Puppet, Ruby, OS and module versions/distributions
- Puppet 4.10.8:
- Ruby: 2.1.9p490
- Distribution: RHEL 6.7
- Module version: 7.1.0
How to reproduce (e.g Puppet code you use)
class {'::splunk::forwarder':
pkg_provider => 'yum',
}
What are you seeing
Puppet gives the following warning:
Warning: Unknown variable: 'staged_package'. at /etc/puppetlabs/code/environments/production/modules/splunk/manifests/forwarder.pp:93:28
What behaviour did you expect instead
No warning.
Output log
Any additional information you'd like to impart
Hi, thanks for rising this bug. Interesting that it is unknown. I am not quite sure how that is possible. Do you call any other class of the splunk module as well?
I only use this class since we only install the splunk forwarder.
@TraGicCode can you take a look please? Any idea?
@bastelfreak I'm actually noticing this on my puppetserver as well ( which is ubuntu ). We should be able to throw together some rspec-puppet tests to reproduce this and hopefully pinpoint and fix the bug. Unfortunately i cannot look at this at the moment as things are very very busy for me with work since we have a huge migration project. I can try and look at this when i get the chance.
It looks like the cause of this is seems to be happening in this giant mess.
https://github.com/voxpupuli/puppet-splunk/blob/26d93aeca889f6486e8a4f689e6cb36f76f7172f/manifests/forwarder.pp#L75-L95
- The conditional there says if package provider is != yum then don't execute the code in the conditional.
- Below the conditional you see some package resource defaults being set. It essentially says if the package provider is not chocolatey then assume the installer for splunk-forwarder is going to come from a downloaded file from the archive resource ( which didn't happen based on the conditional )
This whole mess really need to be cleaned up.
Also inside the params.pp there is some code that really bothers me. It's trying to pick the default package provider based on the node's o/s family fact. This should work on deciding the "default" should be done automatically by the package provider implementations provided by puppet.
https://github.com/voxpupuli/puppet-splunk/blob/26d93aeca889f6486e8a4f689e6cb36f76f7172f/manifests/params.pp#L195-L200
Summary:
There needs to be a refactoring done to unravel this mess and prevent this fragile stuff from breaking in the future.
Just to add, the only way I could get Windows to actually install was like so:
splunk::params::version: '7.0.2'
splunk::params::build: 03bbabbd5c0f
splunk::forwarder::pkg_provider: windows
splunk::forwarder::splunk_user: 'Administrator'
I wanted to use Chocolatey but didn't actually seem possible given the conditions in module. The above forced archive type to download package and install.