From ceb9863749be41e53f200a09ad8fcaa1cb99b263 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Tue, 18 Aug 2020 21:18:52 +0100 Subject: [PATCH 1/2] fix(linux): service.args is freebsd --- prometheus/service/args/clean.sls | 5 ++++- prometheus/service/args/install.sls | 11 ++++++++--- prometheus/service/running.sls | 4 ---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/prometheus/service/args/clean.sls b/prometheus/service/args/clean.sls index 526423b..dc40f2b 100644 --- a/prometheus/service/args/clean.sls +++ b/prometheus/service/args/clean.sls @@ -4,7 +4,9 @@ {%- set tplroot = tpldir.split('/')[0] %} {%- from tplroot ~ "/map.jinja" import prometheus as p with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} -{%- set sls_service_clean = tplroot ~ '.service.clean' %} + +{%- if grains.os_family in ('FreeBSD',) %} + {%- set sls_service_clean = tplroot ~ '.service.clean' %} include: - {{ sls_service_clean }} @@ -36,3 +38,4 @@ prometheus-service-args-clean-{{ name }}: {%- endif %} {%- endfor %} +{%- endif %} diff --git a/prometheus/service/args/install.sls b/prometheus/service/args/install.sls index f4ad0d6..e30b902 100644 --- a/prometheus/service/args/install.sls +++ b/prometheus/service/args/install.sls @@ -4,14 +4,18 @@ {%- set tplroot = tpldir.split('/')[0] %} {%- from tplroot ~ "/map.jinja" import prometheus as p with context %} {%- from tplroot ~ "/libtofs.jinja" import files_switch with context %} -{%- set sls_config_users = tplroot ~ '.config.users' %} -{%- set sls_archive_install = tplroot ~ '.archive.install' %} -{%- set sls_package_install = tplroot ~ '.package.install' %} + +{%- if grains.os_family in ('FreeBSD',) %} + {%- set sls_config_users = tplroot ~ '.config.users' %} + {%- set sls_service_running = tplroot ~ '.service.running' %} + {%- set sls_archive_install = tplroot ~ '.archive.install' %} + {%- set sls_package_install = tplroot ~ '.package.install' %} include: - {{ sls_archive_install if p.pkg.use_upstream_archive else sls_package_install }} - {{ sls_config_users }} + - {{ sls_service_running }} {%- for name in p.wanted.component %} {%- if 'service' in p.pkg.component[name] and 'args' in p.pkg.component[name]['service'] %} @@ -73,3 +77,4 @@ prometheus-service-args-{{ name }}-install: {%- endif %} {%- endif %} {%- endfor %} +{%- endif %} diff --git a/prometheus/service/running.sls b/prometheus/service/running.sls index 8fe3711..da67326 100644 --- a/prometheus/service/running.sls +++ b/prometheus/service/running.sls @@ -5,10 +5,8 @@ {%- from tplroot ~ "/map.jinja" import prometheus as p with context %} {%- set sls_config_file = tplroot ~ '.config.file' %} {%- set sls_config_environ = tplroot ~ '.config.environ' %} -{%- set sls_service_args = tplroot ~ '.service.args.install' %} include: - - {{ sls_service_args }} - {{ sls_config_file }} - {{ sls_config_environ }} @@ -25,7 +23,6 @@ prometheus-service-running-{{ name }}-unmasked: - require_in: - service: prometheus-service-running-{{ name }} - require: - - sls: {{ sls_service_args }} - sls: {{ sls_config_file }} - file: prometheus-config-file-etc-file-directory @@ -43,7 +40,6 @@ prometheus-service-running-{{ name }}: {%- endif %} - enable: True - require: - - sls: {{ sls_service_args }} - sls: {{ sls_config_file }} {%- if p.wanted.firewall %} firewalld.present: From d65858a15426fb91d8e8d862f81c25620e658f4a Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Tue, 18 Aug 2020 21:37:40 +0100 Subject: [PATCH 2/2] fix(permissions): correct basedir user/group --- prometheus/archive/install.sls | 4 ++-- test/integration/default/controls/archive_spec.rb | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/prometheus/archive/install.sls b/prometheus/archive/install.sls index 07f25d8..4c68a4b 100644 --- a/prometheus/archive/install.sls +++ b/prometheus/archive/install.sls @@ -15,8 +15,8 @@ prometheus-archive-install-prerequisites: - names: {{ p.pkg.deps|json }} file.directory: - name: {{ p.dir.var }} - - user: prometheus - - group: prometheus + - user: {{ p.identity.rootuser }} + - group: {{ p.identity.rootgroup }} - mode: 755 - makedirs: True - require: diff --git a/test/integration/default/controls/archive_spec.rb b/test/integration/default/controls/archive_spec.rb index 4d02a50..d2f2c6c 100644 --- a/test/integration/default/controls/archive_spec.rb +++ b/test/integration/default/controls/archive_spec.rb @@ -26,7 +26,6 @@ control 'prometheus components' do end describe directory('/var/lib/prometheus') do it { should exist } - its('group') { should eq 'prometheus' } end describe directory('/opt/prometheus/prometheus-v2.10.0') do it { should exist }