Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collectd network plugin requires two puppet runs #162

Closed
johnf opened this issue Jul 26, 2014 · 12 comments
Closed

Collectd network plugin requires two puppet runs #162

johnf opened this issue Jul 26, 2014 · 12 comments

Comments

@johnf
Copy link

johnf commented Jul 26, 2014

https://github.com/pdxcat/puppet-module-collectd/blob/master/templates/plugin/network.conf.erb#L3

This depends on collectd_version. The fact is being evaluated at catalog compile time which is before collectd is installed. So it probably ends up as nil, so the SecurityLevel isn't set.

Then on a second run when it detects collectd 5 is installed then it adds the SecurityLevel

Not sure what a good solution to this problem is though. Maybe the fact could work out what version is going to be installed? Something like

apt-cache madison collectd | grep Packages | head -1 | awk -F\| '{print $2}' | sed -e 's/-.*//'
@txaj
Copy link

txaj commented Jul 29, 2014

I agree with you, but your suggestion depends too much on the provider used by the package type.

I can't think of a better way to do either

@blkperl
Copy link
Member

blkperl commented Jul 30, 2014

Yeah I haven’t thought of a good solution yet for this problem. It affects all the plugins that check for collectd version.

@txaj
Copy link

txaj commented Jul 30, 2014

When I look on how we use this fact, it appear we are discriminating against a rather big version number. Couldn't we take the approach of discriminating against ::lsbdistrelease ?

@jpoittevin
Copy link
Contributor

I'm not sure it will be enough. If one uses a special repository, he could have a different version of collectd than the one expected with a given dist.

@blkperl
Copy link
Member

blkperl commented Jul 30, 2014

We could add $::lsbdistcodename version defaults and allow it to be overridden by the user but then we have to maintain a list for the life time of the module which is not very appealing.

txaj pushed a commit to txaj/puppet-module-collectd that referenced this issue Feb 19, 2015
txaj pushed a commit to txaj/puppet-module-collectd that referenced this issue Feb 19, 2015
txaj pushed a commit to txaj/puppet-module-collectd that referenced this issue Feb 20, 2015
blkperl added a commit that referenced this issue Apr 4, 2015
Add a section to explain version scoping & known issue for #162
@vladciobancai
Copy link

Any work around about this issue ?

--later :
I have found a small work around that works for me. I have created a facter script to overwrite the collectd_version in order that the plugins to be placed at the first run of puppet.

Facter.add("collectd_version") do
setcode do
"5.4.1-1.7.amzn1"
end
end

@bdellegrazie
Copy link
Contributor

Here is another suggestion:
instead of using the fact directly in the ERB templates, why not use a class variable (e.g. $_collectd_version) which is set based on one of the following sources:

  • $version (if it represents an explicit version - major.minor.revision parts only)
  • $collectd_version fact, if not undef / nil
  • default version supplied from hiera or minimum version supported by this module

This permits the system administrator to use an explicit version for the package and get a single puppet run and/or to supply a default minimum version if these are not set.
e.g. assuming class with defaults as follows (untested)

class collectd(
  ...
  $version  = installed,
  $collectd_default_version = '5.0.0',
) inherits collectd::params {
  ...
   $_collectd_version = pick( regsubst($version, '^\d+\.\d+\.\d+', '\0'), $collectd_version, $collectd_default_version)
  ...
}

Then use $_collectd_version in the ERB templates.

What do you think? If you think its worthwhile I can attempt a pull request.

openstack-gerrit pushed a commit to openstack-archive/fuel-plugin-lma-collector that referenced this issue Aug 4, 2015
This change includes a workaround for a bug [1] found in the upstream
puppet-collectd module.

[1] voxpupuli/puppet-collectd#162

Change-Id: I560e0436cfefb026d2c7a979091208a399bbe2fd
@bdellegrazie
Copy link
Contributor

@johnf, @txaj, @jpoittevin, @ngagecj:
Any comment on my potential solution above? I'm happy to create a PR if its considered reasonable.
Thanks

@txaj
Copy link

txaj commented Aug 4, 2015

This is a great idea!

In your PR you may want 1/ not to break compatibility by setting the $collectd_default_version to undef, so it'll still need two runs if not explicitly configured 2/ document this feature both in the "usage" section and down the README with a format like "Puppet needs two runs to correctly write my conf, why ?" and refer to this issue

bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this issue Aug 5, 2015
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references voxpupuli#162
@bdellegrazie
Copy link
Contributor

@txaj: I've raised the PR as requested.
I've tested this but it relies upon the user loading the collectd class before instantiating any plugin classes. I'm not sure there's a way around this.
Tests for the plugins have been updated but there isn't an easy way of testing the version selector as its only exposed by an internal variable.
Thoughts?

bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this issue Aug 6, 2015
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references voxpupuli#162
bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this issue Aug 6, 2015
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references voxpupuli#162
@bdellegrazie
Copy link
Contributor

Rebased to current master

bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this issue Aug 20, 2015
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references voxpupuli#162
bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this issue Sep 14, 2015
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references voxpupuli#162
bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this issue Sep 15, 2015
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_real_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references voxpupuli#162
bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this issue Sep 15, 2015
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_real_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references voxpupuli#162
bdellegrazie added a commit to bdellegrazie/puppet-module-collectd that referenced this issue Sep 15, 2015
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_real_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references voxpupuli#162
igalic pushed a commit that referenced this issue Sep 28, 2015
…tions

When an administrator knows the version of collectd that will be used or
at least the minimum version available the need for two puppet runs before
convergence can be avoided or at least minimised.

Instead of using the fact in the templates they now use a class variable
set to one of (in priority order):
* collectd_real_version (i.e. the fact)
* version (the semver matched part of it only)
* minimum_version (undef by default)

Existing behaviour is preserved except for a corner case where version is
set to something specific and collectd is not yet installed. In this case
puppet will only take one run and assume the version specified when creating
the templates

references #162
@igalic
Copy link
Contributor

igalic commented Sep 28, 2015

with the closing of #305 can we close this issue, too?

@igalic igalic closed this as completed Sep 28, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants