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

Add prometheus node-exporter name for Ubuntu #401

Closed
wants to merge 1 commit into from

Conversation

ilhaan
Copy link

@ilhaan ilhaan commented Dec 5, 2019

Pull Request (PR) description

Add package prometheus-node-exporter package name for Debian.

This Pull Request (PR) fixes the following issues

Installation on Ubuntu 18.04

@anarcat
Copy link

anarcat commented Dec 18, 2019

PR #303 used to do this. because this change breaks other expectations (it's why tests fail here), I pulled it out to make it easier to merge debian support.

instead of patching the module here, I call the profile with this:

# our node exporter configuration
#
# @param ensure if this node_exporter should be added or removed
class profile::prometheus::node_exporter(
  Enum['present', 'absent'] $ensure = 'present',
) {
  $package_ensure = $ensure ? { 'present' => 'installed', 'absent' => 'absent' }
  $service_ensure = $ensure ? { 'present' => 'running', 'absent'  => 'stopped' }
  class { 'prometheus::node_exporter':
    package_ensure    => $package_ensure,
    service_ensure    => $service_ensure,
    export_scrape_job => true,
    scrape_job_labels => {
      'alias'   => $facts['fqdn'],
      'classes' => join(lookup('classes', Data, 'first', []), ',')
    },
    # force debian package install parameters, further discussion in:
    # https://github.com/voxpupuli/puppet-prometheus/pull/303
    install_method    => 'package',
    init_style        => 'none',
    user              => 'prometheus',
    group             => 'prometheus',
    package_name      => 'prometheus-node-exporter',
    service_name      => 'prometheus-node-exporter',
    # purge_config_dir => true,
  }

  # XXX: should be using apt::pin, but that involves replacing a lot
  # of our custom code
  file {
    '/etc/apt/preferences.d/prometheus-node-exporter.pref':
      ensure  => (versioncmp($::lsbmajdistrelease, '9') <= 0) ? {
        true  => 'present',
        false => 'absent',
      },
      content => "# this file is managed through puppet, local changes will be lost
Explanation: Prometheus 2.x is not in Debian stretch, remove when we move to buster
Package: prometheus-node-exporter
Pin: release n=stretch-backports
Pin-Priority: 500
",
      notify  => Package['prometheus-node-exporter'],
  }
}

.. but I would love to see this fixed in the upstream code as well. note that you also need to fix the package_name if you want to install from packages, and you will also need to perform this change across other exporters as well...

so it is not as simple as it first looks. :)

good luck!

@anarcat anarcat mentioned this pull request Mar 1, 2021
@ilhaan ilhaan closed this Apr 17, 2024
@ilhaan ilhaan deleted the node-exporter-ubuntu-name branch April 17, 2024 21:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants