-
Notifications
You must be signed in to change notification settings - Fork 2
/
macros.jinja2
52 lines (50 loc) · 1.45 KB
/
macros.jinja2
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
49
50
51
52
{%- set user = salt['cmd.run']('stat -f "%Su" /dev/console') %}
{%- set home = salt['user.info'](user)['home'] %}
{%- set downloads = home + '/Downloads' %}
{%- macro dmg_install(name, version, source, source_hash, filename=None, volume=None, app_name=None, pkg=False) %}
{%- if not filename -%}
{%- set filename = name + '-' + version -%}
{%- endif -%}
{%- if not volume -%}
{%- set volume = name|capitalize -%}
{%- endif -%}
{%- if not app_name -%}
{%- set app_name = volume + '.app' -%}
{%- endif %}
{{ name }}:
file:
- managed
- name: {{ downloads }}/{{ filename }}.dmg
- source: {{ source }}
- source_hash: {{ source_hash }}
- user: {{ user }}
hdiutil:
- mounted
- name: {{ downloads }}/{{ filename }}.dmg
- user: {{ user }}
{%- if pkg %}
- unless: pkgutil --pkgs | grep {{ name }}
{%- else %}
- unless: grep {{ version }} /Applications/{{ app_name }}/Contents/Info.plist
{%- endif %}
- require:
- file: {{ name }}
cmd:
- wait
- cwd: /Volumes/{{ volume }}
{%- if pkg %}
- name: sudo installer -verbose -pkg /Volumes/{{ volume }}/*.pkg -target /
{%- else %}
- name: rsync -a --delete {{ app_name }}/ /Applications/{{ app_name }}/
{%- endif %}
- user: {{ user }}
- watch:
- hdiutil: {{ name }}
module:
- wait
- name: hdiutil.unmount
- m_name: /Volumes/{{ volume }}/
- user: {{ user }}
- watch:
- cmd: {{ name }}
{%- endmacro %}