puppet-splunk icon indicating copy to clipboard operation
puppet-splunk copied to clipboard

Warning unknown variable 'staged_package' when `yum` is used as package provider

Open rmestrum opened this issue 7 years ago • 6 comments

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

rmestrum avatar Jan 29 '18 08:01 rmestrum

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?

bastelfreak avatar Jan 29 '18 09:01 bastelfreak

I only use this class since we only install the splunk forwarder.

rmestrum avatar Jan 29 '18 09:01 rmestrum

@TraGicCode can you take a look please? Any idea?

bastelfreak avatar Jan 29 '18 09:01 bastelfreak

@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.

TraGicCode avatar Feb 28 '18 13:02 TraGicCode

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

  1. The conditional there says if package provider is != yum then don't execute the code in the conditional.
  2. 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.

TraGicCode avatar Feb 28 '18 15:02 TraGicCode

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.

treydock avatar Mar 12 '18 13:03 treydock