feat(repository): add support for pkgrepo.managed
BREAKING CHANGE: the variable 'pkg' was renamed 'pkg.name', update your pillars
This commit is contained in:
parent
ea84c92767
commit
907f9a6276
@ -2,7 +2,8 @@
|
|||||||
# vim: ft=yaml
|
# vim: ft=yaml
|
||||||
---
|
---
|
||||||
prometheus:
|
prometheus:
|
||||||
pkg: prometheus
|
pkg:
|
||||||
|
name: prometheus
|
||||||
config_file: /etc/prometheus/prometheus.yml
|
config_file: /etc/prometheus/prometheus.yml
|
||||||
service:
|
service:
|
||||||
name: prometheus
|
name: prometheus
|
||||||
|
@ -2,7 +2,16 @@
|
|||||||
# vim: ft=yaml
|
# vim: ft=yaml
|
||||||
---
|
---
|
||||||
prometheus:
|
prometheus:
|
||||||
pkg: prometheus
|
pkg:
|
||||||
|
name: prometheus
|
||||||
|
use_upstream_repo: False
|
||||||
|
repo:
|
||||||
|
humanname: prometheus
|
||||||
|
name: prometheus
|
||||||
|
comments:
|
||||||
|
- installed by salt
|
||||||
|
enabled: 1
|
||||||
|
gpgcheck: 1
|
||||||
rootgroup: root
|
rootgroup: root
|
||||||
config_file: /etc/prometheus/prometheus.yml
|
config_file: /etc/prometheus/prometheus.yml
|
||||||
config: {}
|
config: {}
|
||||||
@ -12,5 +21,6 @@ prometheus:
|
|||||||
group: prometheus
|
group: prometheus
|
||||||
exporters:
|
exporters:
|
||||||
node:
|
node:
|
||||||
pkg: prometheus-node-exporter
|
pkg:
|
||||||
|
name: prometheus-node-exporter
|
||||||
service: prometheus-node-exporter
|
service: prometheus-node-exporter
|
||||||
|
@ -12,7 +12,7 @@ prometheus-exporters-node-service-dead:
|
|||||||
|
|
||||||
prometheus-exporters-node-pkg-removed:
|
prometheus-exporters-node-pkg-removed:
|
||||||
pkg.removed:
|
pkg.removed:
|
||||||
- name: {{ prometheus.exporters.node.pkg }}
|
- name: {{ prometheus.exporters.node.pkg.name }}
|
||||||
- require:
|
- require:
|
||||||
- service: prometheus-exporters-node-service-dead
|
- service: prometheus-exporters-node-service-dead
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
prometheus-exporters-node-pkg-installed:
|
prometheus-exporters-node-pkg-installed:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
- name: {{ prometheus.exporters.node.pkg }}
|
- name: {{ prometheus.exporters.node.pkg.name }}
|
||||||
|
|
||||||
{%- if 'args' in prometheus.exporters.node %}
|
{%- if 'args' in prometheus.exporters.node %}
|
||||||
{%- set args = prometheus.exporters.node.get('args', {}) -%}
|
{%- set args = prometheus.exporters.node.get('args', {}) -%}
|
||||||
|
14
prometheus/jinja/macros.jinja
Normal file
14
prometheus/jinja/macros.jinja
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=jinja
|
||||||
|
#
|
||||||
|
# Collection of common macros
|
||||||
|
|
||||||
|
{%- macro format_kwargs(kwarg) -%}
|
||||||
|
|
||||||
|
{%- filter indent(4) %}
|
||||||
|
{%- for k, v in kwarg|dictsort() %}
|
||||||
|
- {{ k }}: {{ v }}
|
||||||
|
{%- endfor %}
|
||||||
|
{%- endfilter %}
|
||||||
|
|
||||||
|
{%- endmacro %}
|
@ -11,6 +11,7 @@
|
|||||||
# osfamilymap: {}
|
# osfamilymap: {}
|
||||||
---
|
---
|
||||||
{%- if grains.os == 'MacOS' %}
|
{%- if grains.os == 'MacOS' %}
|
||||||
|
{% set macos_user = salt['cmd.run']("stat -f '%Su' /dev/console") %}
|
||||||
{% set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
|
{% set macos_group = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
@ -20,7 +21,13 @@ Debian:
|
|||||||
node:
|
node:
|
||||||
config_file: /etc/default/prometheus-node-exporter
|
config_file: /etc/default/prometheus-node-exporter
|
||||||
|
|
||||||
RedHat: {}
|
RedHat:
|
||||||
|
pkg:
|
||||||
|
use_upstream_repo: True
|
||||||
|
repo:
|
||||||
|
baseurl: 'https://packagecloud.io/prometheus-rpm/release/el/$releasever/$basearch'
|
||||||
|
gpgkey: 'https://packagecloud.io/prometheus-rpm/release/gpgkey gpgkey2=https://raw.githubusercontent.com/lest/prometheus-rpm/master/RPM-GPG-KEY-prometheus-rpm'
|
||||||
|
metadata_expire: 300
|
||||||
|
|
||||||
Suse: {}
|
Suse: {}
|
||||||
|
|
||||||
@ -35,7 +42,8 @@ FreeBSD:
|
|||||||
config_file: /usr/local/etc/prometheus.yml
|
config_file: /usr/local/etc/prometheus.yml
|
||||||
exporters:
|
exporters:
|
||||||
node:
|
node:
|
||||||
pkg: node_exporter
|
pkg:
|
||||||
|
name: node_exporter
|
||||||
service: node_exporter
|
service: node_exporter
|
||||||
|
|
||||||
OpenBSD:
|
OpenBSD:
|
||||||
@ -46,4 +54,5 @@ Solaris: {}
|
|||||||
Windows: {}
|
Windows: {}
|
||||||
|
|
||||||
MacOS:
|
MacOS:
|
||||||
|
rootuser: {{ macos_user | d('') }}
|
||||||
rootgroup: {{ macos_group | d('') }}
|
rootgroup: {{ macos_group | d('') }}
|
||||||
|
@ -9,8 +9,13 @@
|
|||||||
include:
|
include:
|
||||||
- {{ sls_config_clean }}
|
- {{ sls_config_clean }}
|
||||||
|
|
||||||
|
{%- if prometheus.pkg.use_upstream_repo %}
|
||||||
|
include:
|
||||||
|
- .repo.clean
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
prometheus-package-clean-pkg-removed:
|
prometheus-package-clean-pkg-removed:
|
||||||
pkg.removed:
|
pkg.removed:
|
||||||
- name: {{ prometheus.pkg }}
|
- name: {{ prometheus.pkg.name }}
|
||||||
- require:
|
- require:
|
||||||
- sls: {{ sls_config_clean }}
|
- sls: {{ sls_config_clean }}
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
{%- set tplroot = tpldir.split('/')[0] %}
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
||||||
|
|
||||||
|
{%- if prometheus.pkg.use_upstream_repo %}
|
||||||
|
include:
|
||||||
|
- .repo
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
prometheus-package-install-pkg-installed:
|
prometheus-package-install-pkg-installed:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
- name: {{ prometheus.pkg }}
|
- name: {{ prometheus.pkg.name }}
|
||||||
|
10
prometheus/package/repo/clean.sls
Normal file
10
prometheus/package/repo/clean.sls
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
||||||
|
|
||||||
|
prometheus-package-repo-clean-pkgrepo-absent:
|
||||||
|
pkgrepo.absent:
|
||||||
|
- name: {{ prometheus.pkg.repo.name }}
|
5
prometheus/package/repo/init.sls
Normal file
5
prometheus/package/repo/init.sls
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
include:
|
||||||
|
- .install
|
23
prometheus/package/repo/install.sls
Normal file
23
prometheus/package/repo/install.sls
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
# vim: ft=sls
|
||||||
|
|
||||||
|
{#- Get the `tplroot` from `tpldir` #}
|
||||||
|
{%- set tplroot = tpldir.split('/')[0] %}
|
||||||
|
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
||||||
|
|
||||||
|
{%- if prometheus.pkg.use_upstream_repo %}
|
||||||
|
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}
|
||||||
|
|
||||||
|
prometheus-package-repo-install-pkgrepo-managed:
|
||||||
|
pkgrepo.managed:
|
||||||
|
{{- format_kwargs(prometheus.pkg.repo) }}
|
||||||
|
|
||||||
|
prometheus-package-repo-install-file-replace-workaround-for-salt-51494:
|
||||||
|
file.replace:
|
||||||
|
- name: /etc/yum.repos.d/prometheus.repo
|
||||||
|
- pattern: ' gpgkey2='
|
||||||
|
- repl: '\n '
|
||||||
|
- ignore_if_missing: True
|
||||||
|
- onlyif: {{ grains.os_family == 'RedHat' }}
|
||||||
|
|
||||||
|
{%- endif %}
|
Loading…
Reference in New Issue
Block a user