saltstack-formulas / prometheus-formula

Manage a Prometheus installation
Other
27 stars 51 forks source link

feat(repository): add support for centOS repo #4

Closed noelmcloughlin closed 5 years ago

noelmcloughlin commented 5 years ago

This PR adds support for prometheus repo on RedHat. The implementation required a workaround for https://github.com/saltstack/salt/issues/51494

BREAKING CHANGE: the variable 'pkg' was renamed 'pkg.name', update your pillars One state failed due to https://github.com/saltstack-formulas/prometheus-formula/issues/3

          ID: prometheus-package-repo-install-pkgrepo-managed
    Function: pkgrepo.managed
        Name: prometheus
      Result: True
     Comment: Configured package repo 'prometheus'
     Started: 00:18:22.735432
    Duration: 466.209 ms
     Changes:   
              ----------
              gpgkey:
                  ----------
                  new:
                      https://packagecloud.io/prometheus-rpm/release/gpgkey gpgkey2=https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm
                  old:

----------
          ID: prometheus-package-repo-install-pkgrepo-workaround-salt-51494
    Function: file.replace
        Name: /etc/yum.repos.d/prometheus.repo
      Result: True
     Comment: Changes were made
     Started: 00:18:23.203215
    Duration: 469.286 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -1,7 +1,8 @@
                   [prometheus]
                   metadata_expire=300
                   name=prometheus
                  -gpgkey=https://packagecloud.io/prometheus-rpm/release/gpgkey gpgkey2=https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm
                  +gpgkey=https://packagecloud.io/prometheus-rpm/release/gpgkey
                  +       https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm
                   enabled=1
                   baseurl=https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch
----------
          ID: prometheus-package-install-pkg-installed
    Function: pkg.installed
        Name: prometheus
      Result: True
     Comment: The following packages were installed/updated: prometheus
     Started: 00:18:23.680809
    Duration: 35420.618 ms
     Changes:   
              ----------
              gpg-pubkey.(none):
                  ----------
                  new:
                      168a1ea1-58138084,352c64e5-52ae6884,7457ccd1-58071431,de57bfbe-53a9be98,f4a80eb5-53a7ff4b
                  old:
                      352c64e5-52ae6884,7457ccd1-58071431,de57bfbe-53a9be98,f4a80eb5-53a7ff4b
              prometheus:
                  ----------
                  new:
                      1.8.2-1.el7.centos
                  old:
----------
          ID: prometheus-config-file-file-managed
    Function: file.managed
        Name: /etc/prometheus/prometheus.yml
      Result: True
     Comment: File /etc/prometheus/prometheus.yml updated
     Started: 00:18:59.106292
    Duration: 130.952 ms
     Changes:   
              ----------
              diff:
                  --- 
                  +++ 
                  @@ -1,27 +1,6 @@
                  -# my global config
                  -global:
                  -  scrape_interval:     15s # Set the scrape interval to every 15 seconds. Default is every 1 minute.
                  -  evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute.
                  -  # scrape_timeout is set to the global default (10s).
                  +########################################################################
                  +# File managed by Salt at <salt://prometheus/files/default/prometheus.yml.jinja>.
                  +# Your changes will be overwritten.
                  +########################################################################

                  -  # Attach these labels to any time series or alerts when communicating with
                  -  # external systems (federation, remote storage, Alertmanager).
                  -  external_labels:
                  -      monitor: 'codelab-monitor'
                  -
                  -# Load rules once and periodically evaluate them according to the global 'evaluation_interval'.
                  -rule_files:
                  -  # - "first.rules"
                  -  # - "second.rules"
                  -
                  -# A scrape configuration containing exactly one endpoint to scrape:
                  -# Here it's Prometheus itself.
                  -scrape_configs:
                  -  # The job name is added as a label `job=<job_name>` to any timeseries scraped from this config.
                  -  - job_name: 'prometheus'
                  -
                  -    # metrics_path defaults to '/metrics'
                  -    # scheme defaults to 'http'.
                  -
                  -    static_configs:
                  -      - targets: ['localhost:9090']
                  +{}
----------
          ID: prometheus-service-running-service-running
    Function: service.running
        Name: prometheus
      Result: False
     Comment: The following requisites were not found:
                                 require:
                                     sls: prometheus.config.args
noelmcloughlin commented 5 years ago

The repo file:

[vagrant@localhost ~]$ cat /etc/yum.repos.d/prometheus.repo
[prometheus]
metadata_expire=300
name=prometheus
gpgkey=https://packagecloud.io/prometheus-rpm/release/gpgkey
       https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm
enabled=1
baseurl=https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch
gpgkey2=https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm
gpgcheck=1
# installed by salt
myii commented 5 years ago

@noelmcloughlin Likewise.

noelmcloughlin commented 5 years ago

@noelmcloughlin Likewise.

Thanks thats done @myii

noelmcloughlin commented 5 years ago

Hi @alxwr When you have time, could you review some of the PRs on grafana and prometheus? They are okay on Ubuntu. Need further testing on CentOS. thx.

noelmcloughlin commented 5 years ago

ping @alxwr this to fix CentOS.

noelmcloughlin commented 5 years ago

This is the CentOS error.

      ID: prometheus-package-install-prometheus-installed
    Function: pkg.installed
        Name: prometheus
      Result: False
     Comment: Error occurred installing package(s). Additional info follows:

              errors:
                  - Running scope as unit run-18469.scope.
                    Loaded plugins: fastestmirror
                    Loading mirror speeds from cached hostfile
                     * base: mirrors.clouvider.net
                     * epel: mirror.infonline.de
                     * extras: mirrors.ukfast.co.uk
                     * updates: mirrors.clouvider.net
                    No package prometheus available.
                    Error: Nothing to do
     Started: 23:11:42.180729
    Duration: 29495.127 ms
     Changes:   
noelmcloughlin commented 5 years ago

Thanks @myii for reviewing

saltstack-formulas-travis commented 5 years ago

:tada: This PR is included in version 2.0.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket: