Merge pull request #252 from noelmcloughlin/fixes

Only download archive if necessary [macos]
This commit is contained in:
Niels Abspoel 2019-01-28 20:37:37 +01:00 committed by GitHub
commit e7a309de9b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,18 +1,10 @@
{%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres as pg with context -%} {%- from salt.file.dirname(tpldir) ~ "/map.jinja" import postgres as pg with context -%}
# Cleanup first
pg-remove-prev-archive:
file.absent:
- name: '{{ pg.macos.tmpdir }}/{{ pg.macos.archive }}'
- require_in:
- pg-extract-dirs
pg-extract-dirs: pg-extract-dirs:
file.directory: file.directory:
- names: - names:
- '{{ pg.macos.tmpdir }}' - '{{ pg.macos.tmpdir }}'
- makedirs: True - makedirs: True
- clean: True
- require_in: - require_in:
- pg-download-archive - pg-download-archive
@ -20,11 +12,14 @@ pg-download-archive:
pkg.installed: pkg.installed:
- name: curl - name: curl
cmd.run: cmd.run:
- name: curl {{ pg.macos.dl.opts }} -o '{{ pg.macos.tmpdir }}/{{ pg.macos.archive }}' {{ pg.macos.postgresapp.url }} - name: curl {{ pg.macos.dl.opts }} -o {{ pg.macos.tmpdir }}/{{ pg.macos.archive }} {{ pg.macos.postgresapp.url }}
- unless: test -f {{ pg.macos.tmpdir }}/{{ pg.macos.archive }}
{% if grains['saltversioninfo'] >= [2017, 7, 0] %} {% if grains['saltversioninfo'] >= [2017, 7, 0] %}
- retry: - retry:
attempts: {{ pg.macos.dl.retries }} attempts: {{ pg.macos.dl.retries }}
interval: {{ pg.macos.dl.interval }} interval: {{ pg.macos.dl.interval }}
until: True
splay: 10
{% endif %} {% endif %}
{%- if pg.macos.postgresapp.sum %} {%- if pg.macos.postgresapp.sum %}
@ -33,7 +28,7 @@ pg-check-archive-hash:
- name: file.check_hash - name: file.check_hash
- path: '{{ pg.macos.tmpdir }}/{{ pg.macos.archive }}' - path: '{{ pg.macos.tmpdir }}/{{ pg.macos.archive }}'
- file_hash: {{ pg.macos.postgresapp.sum }} - file_hash: {{ pg.macos.postgresapp.sum }}
- onchanges: - require:
- cmd: pg-download-archive - cmd: pg-download-archive
- require_in: - require_in:
- archive: pg-package-install - archive: pg-package-install
@ -51,14 +46,7 @@ pg-package-install:
- cmd: pg-download-archive - cmd: pg-download-archive
- require_in: - require_in:
- file: pg-package-install - file: pg-package-install
- file: pg-remove-archive
file.append: file.append:
- name: {{ pg.userhomes }}/{{ pg.user }}/.bash_profile - name: {{ pg.userhomes }}/{{ pg.user }}/.bash_profile
- text: 'export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin' - text: 'export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin'
pg-remove-archive:
file.absent:
- name: '{{ pg.macos.tmpdir }}'
- onchanges:
- macpackage: pg-package-install