fix(windows): windows has no osarch grain

This commit is contained in:
noelmcloughlin 2020-11-03 09:34:46 +00:00
parent 79db2125f7
commit 468e420b34
8 changed files with 44 additions and 16 deletions

View File

@ -89,8 +89,8 @@ prometheus-archive-install-{{ name }}-file-directory:
- group: {{ name }} - group: {{ name }}
- mode: '0755' - mode: '0755'
- require: - require:
- user: prometheus-config-user-install-{{ name }}-user-present - user: prometheus-config-users-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present - group: prometheus-config-users-install-{{ name }}-group-present
{%- endif %} {%- endif %}
{%- if grains.kernel|lower == 'linux' %} {%- if grains.kernel|lower == 'linux' %}
@ -122,8 +122,8 @@ prometheus-archive-install-{{ name }}-managed-service:
- require: - require:
- file: prometheus-archive-install-{{ name }}-file-directory - file: prometheus-archive-install-{{ name }}-file-directory
- archive: prometheus-archive-install-{{ name }} - archive: prometheus-archive-install-{{ name }}
- user: prometheus-config-user-install-{{ name }}-user-present - user: prometheus-config-users-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present - group: prometheus-config-users-install-{{ name }}-group-present
cmd.run: cmd.run:
- name: systemctl daemon-reload - name: systemctl daemon-reload
- require: - require:

View File

@ -16,16 +16,18 @@ include:
prometheus-clientlibs-install-{{ name }}: prometheus-clientlibs-install-{{ name }}:
file.directory: file.directory:
- name: {{ p.pkg.clientlibs[name]['path'] }} - name: {{ p.pkg.clientlibs[name]['path'] }}
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
- mode: '0755'
- makedirs: True - makedirs: True
- require_in: - require_in:
- archive: prometheus-clientlibs-install-{{ name }} - archive: prometheus-clientlibs-install-{{ name }}
{%- if grains.os|lower != 'windows' %}
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
- mode: '0755'
- recurse: - recurse:
- user - user
- group - group
- mode - mode
{%- endif %}
archive.extracted: archive.extracted:
{{- format_kwargs(p.pkg.clientlibs[name]['archive']) }} {{- format_kwargs(p.pkg.clientlibs[name]['archive']) }}
- trim_output: true - trim_output: true
@ -33,7 +35,9 @@ prometheus-clientlibs-install-{{ name }}:
- force: {{ p.force }} - force: {{ p.force }}
- options: --strip-components=1 - options: --strip-components=1
- retry: {{ p.retry_option|json }} - retry: {{ p.retry_option|json }}
{%- if grains.os|lower != 'windows' %}
- user: {{ p.identity.rootuser }} - user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }} - group: {{ p.identity.rootgroup }}
{%- endif %}
{%- endfor %} {%- endfor %}

View File

@ -46,8 +46,8 @@ prometheus-config-file-{{ name }}-file-managed:
config: {{ p.pkg.component[name]['config']|json }} config: {{ p.pkg.component[name]['config']|json }}
- require: - require:
- file: prometheus-config-file-etc-file-directory - file: prometheus-config-file-etc-file-directory
- user: prometheus-config-user-install-{{ name }}-user-present - user: prometheus-config-users-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present - group: prometheus-config-users-install-{{ name }}-group-present
- watch_in: - watch_in:
- service: prometheus-service-running-{{ name }} - service: prometheus-service-running-{{ name }}

View File

@ -6,11 +6,13 @@
{%- for name in p.wanted.component %} {%- for name in p.wanted.component %}
prometheus-config-user-install-{{ name }}-user-present: prometheus-config-users-install-{{ name }}-group-present:
group.present: group.present:
- name: {{ name }} - name: {{ name }}
- require_in: - require_in:
- user: prometheus-config-user-install-{{ name }}-user-present - user: prometheus-config-users-install-{{ name }}-user-present
prometheus-config-users-install-{{ name }}-user-present:
user.present: user.present:
- name: {{ name }} - name: {{ name }}
- groups: - groups:
@ -23,4 +25,5 @@ prometheus-config-user-install-{{ name }}-user-present:
- unless: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1 - unless: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1
{%- endif %} {%- endif %}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
# vim: ft=yaml
#
# Setup variables using grains['cuparch'] based logic.
# You just need to add the key:values for an `osarch` that differ
# from `defaults.yaml` + `os_family.yaml`.
# Only add an `cpuarch` which is/will be supported by the formula
#
# If you do not need to provide defaults via the `cpuarch` grain,
# you will need to provide at least an empty dict in this file, e.g.
# cpuarch: {}
---
# Windows has no 'osarch' grain
Default:
dingdong: null
AMD64:
arch: amd64

View File

@ -23,8 +23,8 @@ prometheus-exporters-{{ name }}-collector-textfile-dir:
{%- endif %} {%- endif %}
- makedirs: True - makedirs: True
- requre: - requre:
- user: prometheus-config-user-install-{{ name }}-user-present - user: prometheus-config-users-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present - group: prometheus-config-users-install-{{ name }}-group-present
{%- endif %} {%- endif %}
{%- for k, v in p.get('exporters', {}).get(name, {}).get('textfile_collectors', {}).items() %} {%- for k, v in p.get('exporters', {}).get(name, {}).get('textfile_collectors', {}).items() %}

View File

@ -4,6 +4,7 @@
{%- set tplroot = tpldir.split('/')[0] %} {%- set tplroot = tpldir.split('/')[0] %}
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %} {%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %} {%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
{%- import_yaml tplroot ~ "/cpuarchmap.yaml" as cpuarchmap %}
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %} {%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
{%- set _config = salt['config.get'](tplroot, default={}) %} {%- set _config = salt['config.get'](tplroot, default={}) %}
@ -12,11 +13,13 @@
default=tplroot, default=tplroot,
merge=salt['grains.filter_by']( osfamilymap, grain='os_family', merge=salt['grains.filter_by']( osfamilymap, grain='os_family',
merge=salt['grains.filter_by']( osarchmap, grain='osarch', merge=salt['grains.filter_by']( osarchmap, grain='osarch',
merge=salt['grains.filter_by']( cpuarchmap, grain='cpuarch',
merge=salt['grains.filter_by']( _config, default='lookup' merge=salt['grains.filter_by']( _config, default='lookup'
) )
) )
) )
) )
)
%} %}
{%- set p = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %} {%- set p = salt['grains.filter_by']( {'defaults': defaults}, default='defaults', merge=_config) %}

View File

@ -31,8 +31,8 @@ prometheus-service-args-{{ name }}-data-dir:
- watch_in: - watch_in:
- service: prometheus-service-running-{{ name }} - service: prometheus-service-running-{{ name }}
- require: - require:
- user: prometheus-config-user-install-{{ name }}-user-present - user: prometheus-config-users-install-{{ name }}-user-present
- group: prometheus-config-user-install-{{ name }}-user-present - group: prometheus-config-users-install-{{ name }}-group-present
{%- endif %} {%- endif %}
{%- if grains.os_family == 'FreeBSD' %} {%- if grains.os_family == 'FreeBSD' %}