fix(service): ensure service file is removed on clean
This commit is contained in:
parent
149dd817f2
commit
c735a6deea
@ -13,7 +13,7 @@ prometheus-formula
|
|||||||
:alt: Semantic Release
|
:alt: Semantic Release
|
||||||
:scale: 100%
|
:scale: 100%
|
||||||
:target: https://github.com/semantic-release/semantic-release
|
:target: https://github.com/semantic-release/semantic-release
|
||||||
Manage Prometheus.
|
Manage Prometheus on MacOS, GNU/Linux and FreeBSD.
|
||||||
|
|
||||||
.. contents:: **Table of Contents**
|
.. contents:: **Table of Contents**
|
||||||
|
|
||||||
|
@ -14,14 +14,16 @@ include:
|
|||||||
|
|
||||||
{%- for name in p.wanted %}
|
{%- for name in p.wanted %}
|
||||||
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
|
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
|
||||||
|
{%- if grains.os_family == 'Suse' %}
|
||||||
|
|
||||||
prometheus-archive-alternatives-install-{{ name }}-home-cmd-run:
|
prometheus-archive-alternatives-install-{{ name }}-home-cmd-run:
|
||||||
cmd.run:
|
cmd.run:
|
||||||
- onlyif: {{ grains.os_family in ('Suse',) }}
|
|
||||||
- name: update-alternatives --install {{ p.dir.basedir }}/{{ bundle }} prometheus-{{ name }}-home {{ p.dir.basedir }}/{{ bundle }} {{p.linux.altpriority}}
|
- name: update-alternatives --install {{ p.dir.basedir }}/{{ bundle }} prometheus-{{ name }}-home {{ p.dir.basedir }}/{{ bundle }} {{p.linux.altpriority}}
|
||||||
- watch:
|
- watch:
|
||||||
- archive: prometheus-archive-install-{{ name }}-archive-extracted
|
- archive: prometheus-archive-install-{{ name }}-archive-extracted
|
||||||
|
|
||||||
|
{%- else %}
|
||||||
|
|
||||||
prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install:
|
prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install:
|
||||||
alternatives.install:
|
alternatives.install:
|
||||||
- name: prometheus-{{ name }}-home
|
- name: prometheus-{{ name }}-home
|
||||||
@ -40,9 +42,9 @@ prometheus-archive-alternatives-install-{{ name }}-home-alternatives-set:
|
|||||||
- require:
|
- require:
|
||||||
- cmd: prometheus-archive-alternatives-install-{{ name }}-home-cmd-run
|
- cmd: prometheus-archive-alternatives-install-{{ name }}-home-cmd-run
|
||||||
- alternatives: prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install
|
- alternatives: prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install
|
||||||
- onlyif: {{ grains.os_family not in ('Suse',) }}
|
|
||||||
|
|
||||||
{% for b in p.pkg[name]['binaries'] %}
|
{%- endif %}
|
||||||
|
{% for b in p.pkg[name]['binaries'] %}
|
||||||
|
|
||||||
prometheus-archive-alternatives-install-{{ name }}-alternatives-install-{{ b }}:
|
prometheus-archive-alternatives-install-{{ name }}-alternatives-install-{{ b }}:
|
||||||
cmd.run:
|
cmd.run:
|
||||||
|
@ -6,9 +6,11 @@
|
|||||||
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
|
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
|
||||||
{%- set sls_alternatives_clean = tplroot ~ '.archive.alternatives.clean' %}
|
{%- set sls_alternatives_clean = tplroot ~ '.archive.alternatives.clean' %}
|
||||||
{%- set sls_users_clean = tplroot ~ '.config.users.clean' %}
|
{%- set sls_users_clean = tplroot ~ '.config.users.clean' %}
|
||||||
|
{%- set sls_service_clean = tplroot ~ '.service.clean' %}
|
||||||
|
|
||||||
include:
|
include:
|
||||||
- {{ sls_users_clean }}
|
- {{ sls_users_clean }}
|
||||||
|
- {{ sls_service_clean }}
|
||||||
- {{ sls_alternatives_clean }}
|
- {{ sls_alternatives_clean }}
|
||||||
|
|
||||||
{%- for name in p.wanted %}
|
{%- for name in p.wanted %}
|
||||||
@ -31,4 +33,3 @@ prometheus-archive-clean-{{ name }}-user-absent:
|
|||||||
prometheus-archive-clean-basedir-file-directory:
|
prometheus-archive-clean-basedir-file-directory:
|
||||||
file.absent:
|
file.absent:
|
||||||
- name: {{ p.dir.basedir }}
|
- name: {{ p.dir.basedir }}
|
||||||
|
|
||||||
|
@ -53,6 +53,8 @@ prometheus-archive-install-{{ name }}-file-directory:
|
|||||||
- archive: prometheus-archive-install-{{ name }}-archive-extracted
|
- archive: prometheus-archive-install-{{ name }}-archive-extracted
|
||||||
- file: prometheus-config-file-basedir-file-directory
|
- file: prometheus-config-file-basedir-file-directory
|
||||||
|
|
||||||
|
{%- if grains.os_family not in ('MacOS', 'FreeBSD', 'Windows') %}
|
||||||
|
|
||||||
prometheus-archive-install-{{ name }}-managed-service:
|
prometheus-archive-install-{{ name }}-managed-service:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: {{ p.dir.service }}/{{ name }}.service
|
- name: {{ p.dir.service }}/{{ name }}.service
|
||||||
@ -81,6 +83,7 @@ prometheus-archive-install-{{ name }}-managed-service:
|
|||||||
- require:
|
- require:
|
||||||
- file: prometheus-archive-install-{{ name }}-managed-service
|
- file: prometheus-archive-install-{{ name }}-managed-service
|
||||||
|
|
||||||
|
{%- endif %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -10,6 +10,9 @@
|
|||||||
prometheus-config-user-clean-{{ name }}-user-absent:
|
prometheus-config-user-clean-{{ name }}-user-absent:
|
||||||
user.absent:
|
user.absent:
|
||||||
- name: {{ name }}
|
- name: {{ name }}
|
||||||
|
{%- if grains.os_family == 'MacOS' %}
|
||||||
|
- onlyif: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1
|
||||||
|
{%- endif %}
|
||||||
group.absent:
|
group.absent:
|
||||||
- name: {{ name }}
|
- name: {{ name }}
|
||||||
- require:
|
- require:
|
||||||
|
@ -18,5 +18,8 @@ prometheus-config-user-install-{{ name }}-user-present:
|
|||||||
- createhome: false
|
- createhome: false
|
||||||
- groups:
|
- groups:
|
||||||
- {{ name }}
|
- {{ name }}
|
||||||
|
{%- if grains.os_family == 'MacOS' %}
|
||||||
|
- unless: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
@ -15,9 +15,17 @@ prometheus-service-clean-{{ name }}-service-dead:
|
|||||||
{%- if grains.kernel|lower == 'linux' %}
|
{%- if grains.kernel|lower == 'linux' %}
|
||||||
- onlyif: systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
|
- onlyif: systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
file.absent:
|
||||||
|
- name: {{ prometheus.dir.service }}/{{ name }}.service
|
||||||
|
- require:
|
||||||
|
- service: prometheus-service-clean-{{ name }}-service-dead
|
||||||
|
cmd.run:
|
||||||
|
- onlyif: {{ grains.kernel|lower == 'linux' }}
|
||||||
|
- name: systemctl daemon-reload
|
||||||
|
- require:
|
||||||
|
- file: prometheus-service-clean-{{ name }}-service-dead
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
prometheus-config-file-var-file-absent:
|
prometheus-config-file-var-file-absent:
|
||||||
|
@ -23,13 +23,13 @@ prometheus-config-file-var-file-directory:
|
|||||||
|
|
||||||
{%- for name in prometheus.wanted %}
|
{%- for name in prometheus.wanted %}
|
||||||
{%- if name in prometheus.service %}
|
{%- if name in prometheus.service %}
|
||||||
|
{%- if grains.kernel|lower == 'linux' %}
|
||||||
|
|
||||||
prometheus-service-running-{{ name }}-service-unmasked:
|
prometheus-service-running-{{ name }}-service-unmasked:
|
||||||
service.unmasked:
|
service.unmasked:
|
||||||
- name: {{ name }}
|
- name: {{ name }}
|
||||||
- require:
|
- require:
|
||||||
- file: prometheus-config-file-var-file-directory
|
- file: prometheus-config-file-var-file-directory
|
||||||
{%- if grains.kernel|lower == 'linux' %}
|
|
||||||
- onlyif:
|
- onlyif:
|
||||||
- systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
|
- systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
@ -43,9 +43,9 @@ prometheus-service-running-{{ name }}-service-running:
|
|||||||
- file: prometheus-config-file-{{ name }}-file-managed
|
- file: prometheus-config-file-{{ name }}-file-managed
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
- require:
|
- require:
|
||||||
- service: prometheus-service-running-{{ name }}-service-unmasked
|
|
||||||
- file: prometheus-config-file-var-file-directory
|
- file: prometheus-config-file-var-file-directory
|
||||||
{%- if grains.kernel|lower == 'linux' %}
|
{%- if grains.kernel|lower == 'linux' %}
|
||||||
|
- service: prometheus-service-running-{{ name }}-service-unmasked
|
||||||
- onlyif: systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
|
- onlyif: systemctl list-unit-files | grep {{ name }} >/dev/null 2>&1
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user