Skip to content

Commit eda47f7

Browse files
fix(repo): use_upstream_repo corrections; separate users state
BREAKING CHANGE: The formula has been refactored to accomodate multiple packages, archives, users, and repos. Update your pillars and top states
1 parent 665e116 commit eda47f7

File tree

20 files changed

+137
-136
lines changed

20 files changed

+137
-136
lines changed

docs/README.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ starts the associated prometheus service.
5353

5454
This state will install the prometheus from archive file only.
5555

56+
``prometheus.archive.alternatives``
57+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
58+
59+
This state will install the prometheus linux alternatives for archives only.
60+
5661
``prometheus.package``
5762
^^^^^^^^^^^^^^^^^^^^
5863

@@ -107,6 +112,11 @@ This state will remove the prometheus package and has a depency on
107112

108113
This state will uninstall the prometheus archive-extracted directory only.
109114

115+
``prometheus.package.archive.alternatives.clean``
116+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
117+
118+
This state will uninstall the prometheus linux alternatives for archives only.
119+
110120
``prometheus.package.repo.clean``
111121
^^^^^^^^^^^^^^^^^^^^^^^^^
112122

pillar.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ prometheus:
66
- prometheus
77
- pushgateway
88
- node_explorer
9+
# no memcached_exporter in upstream repo - only archive
10+
# memcached_exporter
911

1012
use_upstream_repo: False
1113
use_upstream_archive: True

prometheus/archive/alternatives/install.sls

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
{%- set tplroot = tpldir.split('/')[0] %}
66
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
77
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
8-
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
8+
{%- set sls_archive_install = tplroot ~ '.archive' %}
99
1010
{%- if grains.kernel|lower in ('linux',) and p.linux.altpriority|int > 0 %}
1111
@@ -21,8 +21,6 @@ prometheus-archive-alternatives-install-{{ name }}-home-cmd-run:
2121
- name: update-alternatives --install {{ p.dir.basedir }}/{{ bundle }} prometheus-{{ name }}-home {{ p.dir.basedir }}/{{ bundle }} {{p.linux.altpriority}}
2222
- watch:
2323
- archive: prometheus-archive-install-{{ name }}-archive-extracted
24-
- require:
25-
- sls: {{ sls_archive_install }}
2624
2725
prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install:
2826
alternatives.install:
@@ -33,8 +31,6 @@ prometheus-archive-alternatives-install-{{ name }}-home-alternatives-install:
3331
- order: 10
3432
- watch:
3533
- archive: prometheus-archive-install-{{ name }}-archive-extracted
36-
- require:
37-
- sls: {{ sls_archive_install }}
3834
- onlyif: {{ grains.os_family not in ('Suse',) }}
3935
4036
prometheus-archive-alternatives-install-{{ name }}-home-alternatives-set:

prometheus/archive/clean.sls

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
{%- set tplroot = tpldir.split('/')[0] %}
66
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
77
{%- set sls_alternatives_clean = tplroot ~ '.archive.alternatives.clean' %}
8-
9-
{%- if p.use_upstream_archive %}
8+
{%- set sls_users_clean = tplroot ~ '.config.users.clean' %}
109
1110
include:
11+
- {{ sls_users_clean }}
1212
- {{ sls_alternatives_clean }}
1313
1414
{%- for name in p.wanted %}
@@ -31,13 +31,9 @@ prometheus-archive-clean-{{ name }}-user-absent:
3131
3232
{%- endfor %}
3333
34-
prometheus-archive-clean-file-directory:
34+
prometheus-archive-clean-basedir-file-directory:
3535
file.absent:
36-
- names:
37-
- {{ p.dir.basedir }}
38-
- {{ p.dir.etc }}
39-
- {{ p.dir.var }}
36+
- name: {{ p.dir.basedir }}
4037
- require:
4138
- sls: {{ sls_alternatives_clean }}
4239
43-
{%- endif %}

prometheus/archive/install.sls

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,24 @@
66
{%- from tplroot ~ "/map.jinja" import prometheus as p with context %}
77
{%- from tplroot ~ "/jinja/macros.jinja" import format_kwargs with context %}
88
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
9+
{%- set sls_users_install = tplroot ~ '.config.users' %}
910
10-
prometheus-archive-install-file-directory:
11+
include:
12+
- {{ sls_users_install }}
13+
14+
prometheus-config-file-basedir-file-directory:
1115
file.directory:
12-
- names:
13-
- {{ p.dir.basedir }}
14-
- {{ p.dir.etc }}
15-
- {{ p.dir.var }}
16+
- name: {{ p.dir.basedir }}
1617
- user: prometheus
1718
- group: prometheus
1819
- mode: 755
1920
- makedirs: True
21+
# require:
22+
# sls: {{ sls_users_install }}
2023
2124
{%- for name in p.wanted %}
2225
{%- set bundle = name + '-%s.%s-%s'|format(p.pkg[name]['archive_version'], p.kernel, p.arch) %}
2326
24-
prometheus-archive-install-{{ name }}-user-present:
25-
group.present:
26-
- name: {{ name }}
27-
- require_in:
28-
- user: prometheus-archive-install-{{ name }}-user-present
29-
user.present:
30-
- name: {{ name }}
31-
- shell: /bin/false
32-
- createhome: false
33-
- groups:
34-
- {{ name }}
35-
- require_in:
36-
- archive: prometheus-archive-install-{{ name }}-archive-extracted
37-
3827
prometheus-archive-install-{{ name }}-archive-extracted:
3928
archive.extracted:
4029
- name: {{ p.dir.basedir }}
@@ -47,6 +36,8 @@ prometheus-archive-install-{{ name }}-archive-extracted:
4736
- recurse:
4837
- user
4938
- group
39+
- require:
40+
- file: prometheus-config-file-basedir-file-directory
5041
5142
{%- if name in p.service %}
5243
@@ -59,6 +50,7 @@ prometheus-archive-install-{{ name }}-file-directory:
5950
- makedirs: True
6051
- require:
6152
- archive: prometheus-archive-install-{{ name }}-archive-extracted
53+
- file: prometheus-config-file-basedir-file-directory
6254
6355
prometheus-archive-install-{{ name }}-managed-service:
6456
file.managed:
@@ -82,6 +74,7 @@ prometheus-archive-install-{{ name }}-managed-service:
8274
stop: '' #not needed
8375
- require:
8476
- file: prometheus-archive-install-{{ name }}-file-directory
77+
- file: prometheus-config-file-basedir-file-directory
8578
8679
{%- endif %}
8780
{%- endfor %}

prometheus/config/args/clean.sls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,7 @@ prometheus-config-args-{{ name }}-file-absent:
5555
{%- endif %}
5656
{%- endif %}
5757
{%- endfor %}
58+
59+
prometheus-config-file-args-file-absent:
60+
file.absent:
61+
- name: {{ prometheus.dir.args }}

prometheus/config/args/install.sls

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,18 @@
99
{%- set sls_service_install = tplroot ~ '.service' %}
1010
1111
include:
12-
- {{ sls_config_install }}
1312
- {{ sls_service_install }}
13+
- {{ sls_config_install }}
14+
15+
prometheus-config-file-args-file-directory:
16+
file.directory:
17+
- name: {{ prometheus.dir.args }}
18+
- user: prometheus
19+
- group: prometheus
20+
- mode: 755
21+
- makedirs: True
22+
# require:
23+
# sls: {{ sls_config_install }}.users
1424
1525
{%- for name in prometheus.wanted %}
1626
{%- if name in prometheus.config or name in prometheus.service %}
@@ -28,6 +38,8 @@ prometheus-config-args-{{ name }}-data-dir:
2838
- makedirs: True
2939
- watch_in:
3040
- service: prometheus-service-running-{{ name }}-service-running
41+
- require:
42+
- file: prometheus-config-file-args-file-directory
3143
3244
{%- endif %}
3345
{%- if args and grains.os_family == 'FreeBSD' %}
@@ -43,7 +55,7 @@ prometheus-config-args-args-web-listen-address:
4355
{%- endif %}
4456
{%- if 'collector.textfile.directory' in args.keys() %}
4557
46-
prometheus-config-args-{{ name }}--collector-textfile-directory:
58+
prometheus-config-args-{{ name }}-collector-textfile-directory:
4759
sysrc.managed:
4860
- name: {{ name }}_textfile_dir
4961
- value: {{ args.pop('collector.textfile.directory') }}

prometheus/config/clean.sls

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
include:
55
- .file.clean
66
- .args.clean
7+
- .users.clean

prometheus/config/file/clean.sls

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ prometheus-config-file-{{ name }}-file-absent:
1919
- sls: {{ sls_service_clean }}
2020
2121
{%- endfor %}
22+
23+
prometheus-config-file-etc-file-absent:
24+
file.absent:
25+
- name: {{ prometheus.dir.etc }}

prometheus/config/file/install.sls

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,23 @@
55
{%- set tplroot = tpldir.split('/')[0] %}
66
{%- from tplroot ~ "/map.jinja" import prometheus with context %}
77
{%- from tplroot ~ "/libtofs.jinja" import files_switch with context %}
8-
{%- set sls_archive_install = tplroot ~ '.archive.install' %}
9-
{%- set sls_package_install = tplroot ~ '.package.install' %}
8+
{%- set sls_users_install = tplroot ~ '.config.users' %}
9+
{%- set sls_archive_install = tplroot ~ '.archive' %}
10+
{%- set sls_package_install = tplroot ~ '.package' %}
1011
1112
include:
1213
- {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
14+
- {{ sls_users_install }}
15+
16+
prometheus-config-file-etc-file-directory:
17+
file.directory:
18+
- name: {{ prometheus.dir.etc }}
19+
- user: prometheus
20+
- group: prometheus
21+
- mode: 755
22+
- makedirs: True
23+
# require:
24+
# sls: {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
1325
1426
{%- for name in prometheus.wanted %}
1527
{%- if name in prometheus.config or name in prometheus.service %}
@@ -29,7 +41,8 @@ prometheus-config-file-{{ name }}-file-managed:
2941
- context:
3042
config: {{ '' if name not in prometheus.config else prometheus.config[name]|json }}
3143
- require:
32-
- sls: {{ sls_archive_install if prometheus.use_upstream_archive else sls_package_install }}
44+
- file: prometheus-config-file-etc-file-directory
45+
# user: prometheus-config-user-install-{{ name }}-user-present
3346
3447
{%- endif %}
3548
{%- endfor %}

0 commit comments

Comments
 (0)