feat(archive): add support for non official exporters

* add offical pillar true(default) / false
  to use raw source url in component:name:archive:source
* add tar pillar true(default) / false
  to use file instead of tar, some repo provide only the binary
* update archive/install.sls and map.jinja
This commit is contained in:
lagooj 2020-11-10 14:19:30 +01:00
parent aad810fa6a
commit 2ff6b90cd8
2 changed files with 35 additions and 9 deletions

View File

@ -28,14 +28,10 @@ prometheus-archive-install-prerequisites:
{%- for name in p.wanted.component %} {%- for name in p.wanted.component %}
prometheus-archive-install-{{ name }}: prometheus-archive-directory-{{ name }}:
file.directory: file.directory:
- name: {{ p.pkg.component[name]['path'] }} - name: {{ p.pkg.component[name]['path'] }}
- makedirs: True - makedirs: True
- require:
- file: prometheus-archive-install-prerequisites
- require_in:
- archive: prometheus-archive-install-{{ name }}
{%- if grains.os != 'Windows' %} {%- if grains.os != 'Windows' %}
- user: {{ p.identity.rootuser }} - user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }} - group: {{ p.identity.rootgroup }}
@ -45,6 +41,8 @@ prometheus-archive-install-{{ name }}:
- group - group
- mode - mode
{%- endif %} {%- endif %}
prometheus-archive-install-{{ name }}:
{%- if p.pkg.component.get(name).get('archive').get('tar', true) %}
archive.extracted: archive.extracted:
{{- format_kwargs(p.pkg.component[name]['archive']) }} {{- format_kwargs(p.pkg.component[name]['archive']) }}
- trim_output: true - trim_output: true
@ -53,12 +51,24 @@ prometheus-archive-install-{{ name }}:
- force: {{ p.force }} - force: {{ p.force }}
- retry: {{ p.retry_option|json }} - retry: {{ p.retry_option|json }}
- require: - require:
- file: prometheus-archive-install-{{ name }} - file: prometheus-archive-directory-{{ name }}
{%- if grains.os != 'Windows' %} {%- if grains.os != 'Windows' %}
- user: {{ p.identity.rootuser }} - user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }} - group: {{ p.identity.rootgroup }}
{%- endif %} {%- endif %}
{% else %}
file.managed:
- name: {{ p.pkg.component[name]['path'] }}/{{ name }}
- source: {{ p.pkg.component[name]['archive']['source'] }}
- source_hash: {{ p.pkg.component[name]['archive']['source_hash'] }}
- mode: '0755'
- require:
- file: prometheus-archive-directory-{{ name }}
{%- if grains.os != 'Windows' %}
- user: {{ p.identity.rootuser }}
- group: {{ p.identity.rootgroup }}
{%- endif %}
{%- endif %}
{%- if (grains.kernel|lower == 'linux' and p.linux.altpriority|int <= 0) or grains.os_family|lower in ('macos', 'arch') %} {%- if (grains.kernel|lower == 'linux' and p.linux.altpriority|int <= 0) or grains.os_family|lower in ('macos', 'arch') %}
{%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %} {%- if 'commands' in p.pkg.component[name] and p.pkg.component[name]['commands'] is iterable %}
{%- for cmd in p.pkg.component[name]['commands'] %} {%- for cmd in p.pkg.component[name]['commands'] %}
@ -73,7 +83,11 @@ prometheus-archive-install-{{ name }}-file-symlink-{{ cmd }}:
- target: {{ p.pkg.component[name]['path'] }}/{{ cmd }} - target: {{ p.pkg.component[name]['path'] }}/{{ cmd }}
- force: True - force: True
- require: - require:
{%- if p.pkg.component.get(name).get('archive').get('tar', true) %}
- archive: prometheus-archive-install-{{ name }} - archive: prometheus-archive-install-{{ name }}
{% else %}
- file: prometheus-archive-install-{{ name }}
{% endif %}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
@ -125,13 +139,21 @@ prometheus-archive-install-{{ name }}-managed-service:
{%- endif %} {%- endif %}
- require: - require:
- file: prometheus-archive-install-{{ name }}-file-directory - file: prometheus-archive-install-{{ name }}-file-directory
{%- if p.pkg.component.get(name).get('archive').get('tar', true) %}
- archive: prometheus-archive-install-{{ name }} - archive: prometheus-archive-install-{{ name }}
{% else %}
- file: prometheus-archive-install-{{ name }}
{% endif %}
- user: prometheus-config-users-install-{{ name }}-user-present - user: prometheus-config-users-install-{{ name }}-user-present
- group: prometheus-config-users-install-{{ name }}-group-present - group: prometheus-config-users-install-{{ name }}-group-present
cmd.run: cmd.run:
- name: systemctl daemon-reload - name: systemctl daemon-reload
- require: - require:
{%- if p.pkg.component.get(name).get('archive').get('tar', true) %}
- archive: prometheus-archive-install-{{ name }} - archive: prometheus-archive-install-{{ name }}
{% else %}
- file: prometheus-archive-install-{{ name }}
{% endif %}
{%- endif %}{# linux #} {%- endif %}{# linux #}
{%- endif %}{# service #} {%- endif %}{# service #}

View File

@ -34,7 +34,11 @@
{%- set url = '%s-%s.%s-%s.tar.gz'|format(uri, v.version|replace('v',''), p.kernel, p.arch) %} {%- set url = '%s-%s.%s-%s.tar.gz'|format(uri, v.version|replace('v',''), p.kernel, p.arch) %}
{%- set dir = '%s-%s'|format(name, v.version) %} {%- set dir = '%s-%s'|format(name, v.version) %}
{%- do p.pkg.component[name].update({'path': p.dir.archive ~ '/' + dir }) %} {%- do p.pkg.component[name].update({'path': p.dir.archive ~ '/' + dir }) %}
{% if p.pkg.component[name]['archive'].get('official', true) %}
{%- do p.pkg.component[name]['archive'].update({'name': p.dir.archive + '/' + dir, 'source': url}) %} {%- do p.pkg.component[name]['archive'].update({'name': p.dir.archive + '/' + dir, 'source': url}) %}
{% else %}
{%- do p.pkg.component[name]['archive'].update({'name': p.dir.archive + '/' + dir }) %}
{% endif %}
{%- endif %} {%- endif %}
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}