-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.sls
48 lines (42 loc) · 1.41 KB
/
user.sls
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
{% from 'git/map.jinja' import git with context %}
{%- for usr_cfg in git['user_config'] %}
{%- set user = usr_cfg.get('user', 'root') %}
{%- set state = usr_cfg.get('state', 'present') %}
{%- if state == 'present' %}
git_user_config_{{ usr_cfg['key'] }}={{ usr_cfg['value'] }}@{{ user }}-{{ state }}:
git.config_set:
- name: {{ usr_cfg['key'] }}
- user: {{ user }}
{%- if usr_cfg.get('value') | is_list %}
- multivar: {{ usr_cfg['value'] }}
{%- else %}
- value: {{ usr_cfg['value'] }}
{%- endif %}
{%- if usr_cfg.get('repo') %}
- repo: {{ usr_cfg['repo'] }}
{%- else %}
- global: True
{%- endif %}
{%- elif state == 'absent' %}
git_user_config_{{ usr_cfg['key'] }}@{{ user }}-{{ state }}:
git.config_unset:
- name: {{ usr_cfg['key'] }}
- user: {{ user }}
{%- if usr_cfg.get('value') %}
- value_regex: {{ usr_cfg['value'] }}
{%- else %}
- all: True
{%- endif %}
{%- if usr_cfg.get('repo') %}
- repo: {{ usr_cfg['repo'] }}
{%- else %}
- global: True
{%- endif %}
- onfail:
- test: git_user_config{{ usr_cfg['key'] }}@{{ user }}-{{ state }}-info
git_user_config{{ usr_cfg['key'] }}@{{ user }}-{{ state }}-info:
test.show_notification:
- name: {{ usr_cfg['key'] }}@{{ user }}-fail
- text: git.config_unset state module is buggy, see https://github.com/saltstack/salt/issues/65715
{%- endif %}
{%- endfor %}