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
|
||||
---
|
||||
prometheus:
|
||||
pkg: prometheus
|
||||
pkg:
|
||||
name: prometheus
|
||||
config_file: /etc/prometheus/prometheus.yml
|
||||
service:
|
||||
name: prometheus
|
||||
|
@ -2,7 +2,16 @@
|
||||
# vim: ft=yaml
|
||||
---
|
||||
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
|
||||
config_file: /etc/prometheus/prometheus.yml
|
||||
config: {}
|
||||
@ -12,5 +21,6 @@ prometheus:
|
||||
group: prometheus
|
||||
exporters:
|
||||
node:
|
||||
pkg: prometheus-node-exporter
|
||||
pkg:
|
||||
name: prometheus-node-exporter
|
||||
service: prometheus-node-exporter
|
||||
|
@ -12,7 +12,7 @@ prometheus-exporters-node-service-dead:
|
||||
|
||||
prometheus-exporters-node-pkg-removed:
|
||||
pkg.removed:
|
||||
- name: {{ prometheus.exporters.node.pkg }}
|
||||
- name: {{ prometheus.exporters.node.pkg.name }}
|
||||
- require:
|
||||
- service: prometheus-exporters-node-service-dead
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
prometheus-exporters-node-pkg-installed:
|
||||
pkg.installed:
|
||||
- name: {{ prometheus.exporters.node.pkg }}
|
||||
- name: {{ prometheus.exporters.node.pkg.name }}
|
||||
|
||||
{%- if 'args' in prometheus.exporters.node %}
|
||||
{%- 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: {}
|
||||
---
|
||||
{%- 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") %}
|
||||
{%- endif %}
|
||||
|
||||
@ -20,7 +21,13 @@ Debian:
|
||||
node:
|
||||
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: {}
|
||||
|
||||
@ -35,7 +42,8 @@ FreeBSD:
|
||||
config_file: /usr/local/etc/prometheus.yml
|
||||
exporters:
|
||||
node:
|
||||
pkg: node_exporter
|
||||
pkg:
|
||||
name: node_exporter
|
||||
service: node_exporter
|
||||
|
||||
OpenBSD:
|
||||
@ -46,4 +54,5 @@ Solaris: {}
|
||||
Windows: {}
|
||||
|
||||
MacOS:
|
||||
rootuser: {{ macos_user | d('') }}
|
||||
rootgroup: {{ macos_group | d('') }}
|
||||
|
@ -9,8 +9,13 @@
|
||||
include:
|
||||
- {{ sls_config_clean }}
|
||||
|
||||
{%- if prometheus.pkg.use_upstream_repo %}
|
||||
include:
|
||||
- .repo.clean
|
||||
{%- endif %}
|
||||
|
||||
prometheus-package-clean-pkg-removed:
|
||||
pkg.removed:
|
||||
- name: {{ prometheus.pkg }}
|
||||
- name: {{ prometheus.pkg.name }}
|
||||
- require:
|
||||
- sls: {{ sls_config_clean }}
|
||||
|
@ -4,7 +4,12 @@
|
||||
{#- Get the `tplroot` from `tpldir` #}
|
||||
{%- set tplroot = tpldir.split('/')[0] %}
|
||||
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
|
||||
|
||||
{%- if prometheus.pkg.use_upstream_repo %}
|
||||
include:
|
||||
- .repo
|
||||
{%- endif %}
|
||||
|
||||
prometheus-package-install-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