Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(archive): allowing archive options to be overridable #88

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions prometheus/archive/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ prometheus-archive-install-{{ name }}:
{{- format_kwargs(p.pkg.component[name]['archive']) }}
- trim_output: true
- enforce_toplevel: false
- options: --strip-components=1
- force: {{ p.force }}
- retry: {{ p.retry_option|json }}
- require:
Expand Down Expand Up @@ -99,8 +98,8 @@ prometheus-archive-install-{{ name }}-file-directory:
- name: {{ p.dir.var }}{{ p.div }}{{ name }}
- makedirs: True
{%- if grains.os != 'Windows' %}
- user: {{ name }}
- group: {{ name }}
- user: {{ name|truncate(16, False, "") }}
- group: {{ name|truncate(16, False, "") }}
- mode: '0755'
- require:
- user: prometheus-config-users-install-{{ name }}-user-present
Expand All @@ -124,8 +123,8 @@ prometheus-archive-install-{{ name }}-managed-service:
- context:
desc: prometheus - {{ name }} service
name: {{ name }}
user: {{ name }}
group: {{ name }}
user: {{ name|truncate(16, False, "") }}
group: {{ name|truncate(16, False, "") }}
env: {{ p.pkg.component[name]['service'].get('env', [])|tojson }}
workdir: {{ p.dir.var }}/{{ name }}
stop: ''
Expand Down
4 changes: 2 additions & 2 deletions prometheus/config/clean.sls
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ prometheus-config-clean-{{ name }}:
- name: {{ name }}_environ
{%- endif %}
user.absent:
- name: {{ name }}
- name: {{ name|truncate(16, False, "") }}
{%- if grains.os_family == 'MacOS' %}
- onlyif: /usr/bin/dscl . list /Users | grep {{ name }} >/dev/null 2>&1
{%- endif %}
group.absent:
- name: {{ name }}
- name: {{ name|truncate(16, False, "") }}
- require:
- {{ sls_config_clean }}

Expand Down
6 changes: 3 additions & 3 deletions prometheus/config/users.sls
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@

prometheus-config-users-install-{{ name }}-group-present:
group.present:
- name: {{ name }}
- name: {{ name|truncate(16, False, "") }}
- system: true
- require_in:
- user: prometheus-config-users-install-{{ name }}-user-present

prometheus-config-users-install-{{ name }}-user-present:
user.present:
- name: {{ name }}
- name: {{ name|truncate(16, False, "") }}
- groups:
- {{ name }}
- {{ name|truncate(16, False, "") }}
{%- if grains.os != 'Windows' %}
- shell: {{ p.shell }}
{%- if grains.kernel|lower == 'linux' %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ prometheus-exporters-{{ name }}-collector-textfile-dir:
- name: {{ p.pkg.component[name]['service']['args']['collector.textfile.directory'] }}
{%- if grains.os != 'Windows' %}
- mode: 755
- user: {{ name }}
- group: {{ name }}
- user: {{ name|truncate(16, False, "") }}
- group: {{ name|truncate(16, False, "") }}
{%- endif %}
- makedirs: True
- require:
Expand Down
1 change: 1 addition & 0 deletions prometheus/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
{%- for name,v in p.pkg.component.items() %}
{%- set url = None %}
{%- set dir = name %}
{%- do p.pkg.component[name].get('archive', {}).setdefault('options', '--strip-components=1') %}
{%- if 'version' in v and v.version and 'archive' in v and v.archive and 'uri' in p.pkg %}
{%- set uri = '%s/%s/releases/download/%s/%s'|format(p.pkg.uri, name, v.version, name) %}
{%- set url = '%s-%s.%s-%s.tar.gz'|format(uri, v.version|replace('v',''), p.kernel, p.arch) %}
Expand Down
4 changes: 2 additions & 2 deletions prometheus/service/args/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ include:
prometheus-service-args-{{ name }}-data-dir:
file.directory:
- name: {{ args['storage.tsdb.path'] }}
- user: {{ name }}
- group: {{ name }}
- user: {{ name|truncate(16, False, "") }}
- group: {{ name|truncate(16, False, "") }}
- makedirs: True
- watch_in:
- service: prometheus-service-running-{{ name }}
Expand Down
23 changes: 23 additions & 0 deletions test/integration/default/controls/archive_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
describe user('mysqld_exporter') do
it { should exist }
end
describe group('prometheus_bigqu') do
it { should exist }
end
describe user('prometheus_bigqu') do
it { should exist }
end
describe directory('/var/lib/prometheus') do
it { should exist }
end
Expand Down Expand Up @@ -157,6 +163,23 @@
its('group') { should eq 'root' }
its('mode') { should cmp '0644' }
end
describe directory('/opt/prometheus/prometheus_bigquery_remote_storage_adapter-v0.4.6') do # rubocop:disable Layout/LineLength
it { should exist }
its('group') { should eq 'root' }
end
describe file('/opt/prometheus/prometheus_bigquery_remote_storage_adapter-v0.4.6/prometheus_bigquery_remote_storage_adapter') do # rubocop:disable Layout/LineLength
it { should exist }
its('group') { should eq 'root' }
end
describe directory('/var/lib/prometheus/prometheus_bigquery_remote_storage_adapter') do # rubocop:disable Layout/LineLength
it { should exist }
its('group') { should eq 'prometheus_bigqu' }
end
describe file("#{service_dir}/prometheus-bigquery-backend.service") do
it { should exist }
its('group') { should eq 'root' }
its('mode') { should cmp '0644' }
end

describe file('/usr/local/sbin/alertmanager') do
it { should exist }
Expand Down
17 changes: 17 additions & 0 deletions test/salt/pillar/default.sls
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ prometheus:
- postgres_exporter
- mysqld_exporter
- memcached_exporter # not in upstream repo, only archive
- prometheus_bigquery_remote_storage_adapter

exporters:
node_exporter:
Expand Down Expand Up @@ -218,6 +219,22 @@ prometheus:
source: https://github.com/wrouesnel/postgres_exporter/releases/download/v0.8.0/postgres_exporter_v0.8.0_linux-amd64.tar.gz
skip_verify: true

prometheus_bigquery_remote_storage_adapter:
version: v0.4.6
service:
name: prometheus-bigquery-backend
env:
- "PROMBQ_DATASET=prometheus"
- "PROMBQ_TABLE=metrics_stream"
- "PROMBQ_GCP_PROJECT_ID=foobar"
archive:
official: false
name: /opt/prometheus/prometheus_bigquery_remote_storage_adapter
options: "--strip-components=0"
source: https://github.com/KohlsTechnology/prometheus_bigquery_remote_storage_adapter/releases/download/v0.4.6/prometheus_bigquery_remote_storage_adapter_0.4.6_Linux_x86_64.tar.gz # noqa: 204
source_hash: https://github.com/KohlsTechnology/prometheus_bigquery_remote_storage_adapter/releases/download/v0.4.6/checksums.txt
source_hash_name: prometheus_bigquery_remote_storage_adapter_0.4.6_Linux_x86_64.tar.gz

linux:
# 'Alternatives system' priority: zero disables (default)
# yamllint disable-line rule:braces
Expand Down