From 1e527c4b910738f963e53d2a44c0d8cb77b6f389 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Thu, 8 Mar 2018 11:41:19 +0000 Subject: [PATCH 1/2] POSTGRESAPP on MacOS --- README.rst | 14 +++--- pillar.example | 10 +++- postgres/defaults.yaml | 17 +++++++ postgres/dev.sls | 54 ++++++++++++++++++-- postgres/init.sls | 5 ++ postgres/macos/init.sls | 10 ++++ postgres/macos/postgresapp.sls | 67 +++++++++++++++++++++++++ postgres/osmap.yaml | 22 +++++--- postgres/repo.yaml | 8 +++ postgres/templates/limit.maxfiles.plist | 21 ++++++++ postgres/templates/mac_shortcut.sh | 8 +++ 11 files changed, 218 insertions(+), 18 deletions(-) create mode 100644 postgres/macos/init.sls create mode 100644 postgres/macos/postgresapp.sls create mode 100644 postgres/templates/limit.maxfiles.plist create mode 100755 postgres/templates/mac_shortcut.sh diff --git a/README.rst b/README.rst index bd90d90..01ccb04 100644 --- a/README.rst +++ b/README.rst @@ -17,12 +17,12 @@ Available states ------------ Installs and configures both PostgreSQL server and client with creation of various DB objects in -the cluster. +the cluster. This state applies to both Linux and MacOS. ``postgres.client`` ------------------- -Installs the PostgreSQL client binaries and libraries. +Installs the PostgreSQL client binaries and libraries on Linux. ``postgres.manage`` ------------------- @@ -33,18 +33,18 @@ See ``pillar.example`` file for details. ``postgres.python`` ------------------- -Installs the PostgreSQL adapter for Python. +Installs the PostgreSQL adapter for Python on Linux. ``postgres.server`` ------------------- -Installs the PostgreSQL server package, prepares the DB cluster and starts the server using +Installs the PostgreSQL server package on Linux, prepares the DB cluster and starts the server using packaged init script, job or unit. ``postgres.server.image`` ------------------------- -Installs the PostgreSQL server package, prepares the DB cluster and starts the server by issuing +Installs the PostgreSQL server package on Linux, prepares the DB cluster and starts the server by issuing raw ``pg_ctl`` command. The ``postgres:bake_image`` Pillar toggles this behaviour. For example: .. code:: yaml @@ -77,12 +77,14 @@ The state relies on the ``postgres:use_upstream_repo`` Pillar value which could * ``True`` (default): adds the upstream repository to install packages from * ``False``: makes sure that the repository configuration is absent +* ``postgresapp`` (MacOS) uses upstream PostgresApp package repository. The ``postgres:version`` Pillar controls which version of the PostgreSQL packages should be -installed from the upstream repository. Defaults to ``9.5``. +installed from the upstream Linux repository. Defaults to ``9.5``. Testing ======= +The postgres state was tested on MacOS (El Capitan 10.11.6) Testing is done with the ``kitchen-salt``. diff --git a/pillar.example b/pillar.example index e87a238..338c017 100644 --- a/pillar.example +++ b/pillar.example @@ -5,6 +5,10 @@ postgres: # Version to install from upstream repository (if upstream_repo: True) version: '9.6' + ### MACOS + # Set to 'postgresapp' to install that upstream MacOS package + #use_upstream_repo: 'postgresapp' + # PACKAGE # These pillars are typically never required. # pkg: 'postgresql' @@ -14,11 +18,15 @@ postgres: - postgresql-contrib - postgresql-plpython - #'Alternatives system' priority incremental. 0 disables feature. linux: altpriority: 30 + # macos limits + limits: + soft: 64000 + hard: 64000 + # POSTGRES # Append the lines under this item to your postgresql.conf file. # Pay attention to indent exactly with 4 spaces for all lines. diff --git a/postgres/defaults.yaml b/postgres/defaults.yaml index 50b12b8..4a21fa9 100644 --- a/postgres/defaults.yaml +++ b/postgres/defaults.yaml @@ -9,6 +9,8 @@ postgres: pkg_dev: postgresql-devel pkg_libpq_dev: postgresql-libs python: python-psycopg2 + userhomes: /home + systemuser: user: postgres group: postgres @@ -21,6 +23,21 @@ postgres: conf_dir: /var/lib/pgsql/data postgresconf: "" + macos: + archive: postgres.dmg + tmpdir: /tmp/postgrestmp + postgresapp: + #See: https://github.com/PostgresApp/PostgresApp/releases/ + url: https://github.com/PostgresApp/PostgresApp/releases/download/v2.1.1/Postgres-2.1.1.dmg + sum: sha256=ac0656b522a58fd337931313f09509c09610c4a6078fe0b8e469e69af1e1750b + homebrew: + url: + sum: + dl: + opts: -s -L + interval: 60 + retries: 2 + pg_hba.conf: salt://postgres/templates/pg_hba.conf.j2 acls: # "local" is for Unix domain socket connections only diff --git a/postgres/dev.sls b/postgres/dev.sls index 451d478..3e3d1f1 100644 --- a/postgres/dev.sls +++ b/postgres/dev.sls @@ -1,13 +1,61 @@ {% from "postgres/map.jinja" import postgres with context %} -{% if postgres.pkg_dev %} +{% if grains.os not in ('Windows', 'MacOS',) %} + + {% if postgres.pkg_dev %} install-postgres-dev-package: pkg.installed: - name: {{ postgres.pkg_dev }} -{% endif %} + {% endif %} -{% if postgres.pkg_libpq_dev %} + {% if postgres.pkg_libpq_dev %} install-postgres-libpq-dev: pkg.installed: - name: {{ postgres.pkg_libpq_dev }} + {% endif %} + +{% endif %} + + +{% if grains.os == 'MacOS' %} + + # Darwin maxfiles limits + {% if postgres.limits.soft or postgres.limits.hard %} + +postgres_maxfiles_limits_conf: + file.managed: + - name: /Library/LaunchDaemons/limit.maxfiles.plist + - source: salt://postgres/templates/limit.maxfiles.plist + - context: + soft_limit: {{ postgres.limits.soft or postgres.limits.hard }} + hard_limit: {{ postgres.limits.hard or postgres.limits.soft }} + - group: wheel + {% endif %} + + # MacOS Shortcut for system user + {% if postgres.systemuser|lower not in (None, '',) %} + +postgres-desktop-shortcut-clean: + file.absent: + - name: '{{ postgres.userhomes }}/{{ postgres.systemuser }}/Desktop/postgres' + - require_in: + - file: postgres-desktop-shortcut-add + + {% endif %} + +postgres-desktop-shortcut-add: + file.managed: + - name: /tmp/mac_shortcut.sh + - source: salt://postgres/templates/mac_shortcut.sh + - mode: 755 + - template: jinja + - context: + user: {{ postgres.systemuser }} + homes: {{ postgres.userhomes }} + cmd.run: + - name: /tmp/mac_shortcut.sh {{ postgres.use_upstream_repo }} + - runas: {{ postgres.systemuser }} + - require: + - file: postgres-desktop-shortcut-add + {% endif %} diff --git a/postgres/init.sls b/postgres/init.sls index 0409e62..a28a0ed 100644 --- a/postgres/init.sls +++ b/postgres/init.sls @@ -1,4 +1,9 @@ + include: +{% if grains.os == 'MacOS' %} + - postgres.macos +{% else %} - postgres.server - postgres.client - postgres.manage +{% endif %} diff --git a/postgres/macos/init.sls b/postgres/macos/init.sls new file mode 100644 index 0000000..7ebb4ef --- /dev/null +++ b/postgres/macos/init.sls @@ -0,0 +1,10 @@ +{% from "postgres/map.jinja" import postgres with context %} + +include: +{% if postgres.use_upstream_repo == 'postgresapp' %} + - postgres.macos.postgresapp +{% else %} + - postgres.server + - postgres.client +{% endif %} + - postgres.dev diff --git a/postgres/macos/postgresapp.sls b/postgres/macos/postgresapp.sls new file mode 100644 index 0000000..6f5bd4c --- /dev/null +++ b/postgres/macos/postgresapp.sls @@ -0,0 +1,67 @@ +{% from "postgres/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: + file.directory: + - names: + - '{{ pg.macos.tmpdir }}' + - makedirs: True + - clean: True + - require_in: + - pg-download-archive + +pg-download-archive: + pkg.installed: + - name: curl + cmd.run: + - name: curl {{ pg.macos.dl.opts }} -o '{{ pg.macos.tmpdir }}/{{ pg.macos.archive }}' {{ pg.macos.postgresapp.url }} + {% if grains['saltversioninfo'] >= [2017, 7, 0] %} + - retry: + attempts: {{ pg.macos.dl.retries }} + interval: {{ pg.macos.dl.interval }} + {% endif %} + +{%- if pg.macos.postgresapp.sum %} + #Check hashstring for archive downloads + {%- if grains['saltversioninfo'] <= [2016, 11, 6] %} +pg-check-archive-hash: + module.run: + - name: file.check_hash + - path: '{{ pg.macos.tmpdir }}/{{ pg.macos.archive }}' + - file_hash: {{ pg.macos.postgresapp.sum }} + - onchanges: + - cmd: pg-download-archive + - require_in: + - archive: pg-package-install + {%- endif %} +{%- endif %} + +pg-package-install: + macpackage.installed: + - name: '{{ pg.macos.tmpdir }}/{{ pg.macos.archive }}' + - store: True + - dmg: True + - app: True + - force: True + - allow_untrusted: True + - onchanges: + - cmd: pg-download-archive + - require_in: + - file: pg-package-install + - file: pg-remove-archive + file.append: + - name: {{ pg.userhomes }}/{{ pg.systemuser }}/.bash_profile + - 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 + diff --git a/postgres/osmap.yaml b/postgres/osmap.yaml index 4cbd9dd..2e1abe8 100644 --- a/postgres/osmap.yaml +++ b/postgres/osmap.yaml @@ -134,17 +134,23 @@ Suse: {% endif %} MacOS: - service: postgresql + {# todo: homebrew postgresql #} + {% if repo.use_upstream_repo == 'homebrew' %} + service: homebrew.mxcl.postgresql + {% elif repo.use_upstream_repo == 'postgresapp' %} + service: com.postgresapp.Postgres2 + {% endif %} pkg: postgresql pkg_client: pkg_libpq_dev: - conf_dir: /usr/local/var/postgres - user: _postgres - group: _postgres + userhomes: /Users + user: {{ repo.user }} + group: {{ repo.group }} + conf_dir: /Users/{{ repo.user }}/Library/AppSupport/postgres_{{ repo.use_upstream_repo }} prepare_cluster: - command: initdb -D /usr/local/var/postgres/ - test: test -f /usr/local/var/postgres/PG_VERSION - user: _postgres - group: _postgres + command: initdb -D /Users/{{ repo.user }}/Library/AppSupport/postgres_{{ repo.use_upstream_repo }} + test: test -f /Users/{{ repo.user }}/Library/AppSupport/postgres_{{ repo.use_upstream_repo }}/PG_VERSION + user: {{ repo.user }} + group: {{ repo.group }} # vim: ft=sls diff --git a/postgres/repo.yaml b/postgres/repo.yaml index e37eec7..1d87463 100644 --- a/postgres/repo.yaml +++ b/postgres/repo.yaml @@ -8,4 +8,12 @@ use_upstream_repo: {{ salt['pillar.get']('postgres:use_upstream_repo', version: {{ salt['pillar.get']('postgres:version', defaults.postgres.version) }} +#Early lookup for system user on MacOS +{% if grains.os == 'MacOS' %} + {% set sysuser = salt['pillar.get']('postgres.user') or salt['cmd.run']("stat -f '%Su' /dev/console") %} + {% set sysgroup = salt['pillar.get']('postgres.group') or salt['cmd.run']("stat -f '%Sg' /dev/console") %} +user: {{ sysuser }} +group: {{ sysgroup }} +{% endif %} + # vim: ft=sls diff --git a/postgres/templates/limit.maxfiles.plist b/postgres/templates/limit.maxfiles.plist new file mode 100644 index 0000000..84a6437 --- /dev/null +++ b/postgres/templates/limit.maxfiles.plist @@ -0,0 +1,21 @@ + + + + + Label + limit.maxfiles + ProgramArguments + + launchctl + limit + maxfiles + {{ soft_limit }} + {{ hard_limit }} + + RunAtLoad + + ServiceIPC + + + diff --git a/postgres/templates/mac_shortcut.sh b/postgres/templates/mac_shortcut.sh new file mode 100755 index 0000000..a156e24 --- /dev/null +++ b/postgres/templates/mac_shortcut.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash + +vendor=$1 +app="postgres.app" +Source="/Applications/$app" +Destination="{{ homes }}/{{ user }}/Desktop" +/usr/bin/osascript -e "tell application \"Finder\" to make alias file to POSIX file \"$Source\" at POSIX file \"$Destination\"" + From a34a4c270cf3ddca0b1c7b84735738a54bdacd07 Mon Sep 17 00:00:00 2001 From: noelmcloughlin Date: Thu, 8 Mar 2018 12:30:25 +0000 Subject: [PATCH 2/2] Homebrew Postgres on MacOS --- README.rst | 3 ++- pillar.example | 3 ++- postgres/client.sls | 4 +-- postgres/codenamemap.yaml | 4 +-- postgres/dev.sls | 18 ++++++-------- postgres/macos/init.sls | 2 +- postgres/macos/postgresapp.sls | 7 ++---- postgres/osmap.yaml | 14 ++++++----- postgres/server/init.sls | 33 ++++++++++++++++++++----- postgres/templates/limit.maxfiles.plist | 2 +- postgres/templates/mac_shortcut.sh | 4 +-- postgres/upstream.sls | 4 ++- 12 files changed, 60 insertions(+), 38 deletions(-) diff --git a/README.rst b/README.rst index 01ccb04..f28a0b1 100644 --- a/README.rst +++ b/README.rst @@ -77,7 +77,8 @@ The state relies on the ``postgres:use_upstream_repo`` Pillar value which could * ``True`` (default): adds the upstream repository to install packages from * ``False``: makes sure that the repository configuration is absent -* ``postgresapp`` (MacOS) uses upstream PostgresApp package repository. +* ``'postgresapp'`` (MacOS) uses upstream PostgresApp package repository. +* ``'homebrew'`` (MacOS) uses Homebrew postgres The ``postgres:version`` Pillar controls which version of the PostgreSQL packages should be installed from the upstream Linux repository. Defaults to ``9.5``. diff --git a/pillar.example b/pillar.example index 338c017..38f16e8 100644 --- a/pillar.example +++ b/pillar.example @@ -6,8 +6,9 @@ postgres: version: '9.6' ### MACOS - # Set to 'postgresapp' to install that upstream MacOS package + # Set to 'postgresapp' OR 'homebrew' for MacOS #use_upstream_repo: 'postgresapp' + #use_upstream_repo: 'homebrew' # PACKAGE # These pillars are typically never required. diff --git a/postgres/client.sls b/postgres/client.sls index a8729d1..473f3c6 100644 --- a/postgres/client.sls +++ b/postgres/client.sls @@ -7,7 +7,7 @@ {%- endif %} {%- endfor %} -{%- if postgres.use_upstream_repo %} +{%- if postgres.use_upstream_repo == true %} include: - postgres.upstream {%- endif %} @@ -16,7 +16,7 @@ include: postgresql-client-libs: pkg.installed: - pkgs: {{ pkgs }} -{%- if postgres.use_upstream_repo %} +{%- if postgres.use_upstream_repo == true %} - refresh: True - require: - pkgrepo: postgresql-repo diff --git a/postgres/codenamemap.yaml b/postgres/codenamemap.yaml index 909ccde..f5ea154 100644 --- a/postgres/codenamemap.yaml +++ b/postgres/codenamemap.yaml @@ -16,7 +16,7 @@ #} {# use upstream version if configured #} - {% if repo.use_upstream_repo %} + {% if repo.use_upstream_repo == true %} {% set version = repo.version %} {% endif %} @@ -49,7 +49,7 @@ #} {# use upstream version if configured #} - {% if repo.use_upstream_repo %} + {% if repo.use_upstream_repo == true %} {% set version = repo.version %} {% endif %} diff --git a/postgres/dev.sls b/postgres/dev.sls index 3e3d1f1..c9f330b 100644 --- a/postgres/dev.sls +++ b/postgres/dev.sls @@ -29,20 +29,17 @@ postgres_maxfiles_limits_conf: - context: soft_limit: {{ postgres.limits.soft or postgres.limits.hard }} hard_limit: {{ postgres.limits.hard or postgres.limits.soft }} - - group: wheel + - group: {{ postgres.group }} {% endif %} - # MacOS Shortcut for system user - {% if postgres.systemuser|lower not in (None, '',) %} - + {% if postgres.use_upstream_repo == 'postgresapp' %} + # Shortcut for PostgresApp postgres-desktop-shortcut-clean: file.absent: - - name: '{{ postgres.userhomes }}/{{ postgres.systemuser }}/Desktop/postgres' + - name: '{{ postgres.userhomes }}/{{ postgres.user }}/Desktop/Postgres ({{ postgres.use_upstream_repo }})' - require_in: - file: postgres-desktop-shortcut-add - {% endif %} - postgres-desktop-shortcut-add: file.managed: - name: /tmp/mac_shortcut.sh @@ -50,12 +47,13 @@ postgres-desktop-shortcut-add: - mode: 755 - template: jinja - context: - user: {{ postgres.systemuser }} + user: {{ postgres.user }} homes: {{ postgres.userhomes }} cmd.run: - - name: /tmp/mac_shortcut.sh {{ postgres.use_upstream_repo }} - - runas: {{ postgres.systemuser }} + - name: '/tmp/mac_shortcut.sh "Postgres ({{ postgres.use_upstream_repo }})"' + - runas: {{ postgres.user }} - require: - file: postgres-desktop-shortcut-add + {% endif %} {% endif %} diff --git a/postgres/macos/init.sls b/postgres/macos/init.sls index 7ebb4ef..ed332ad 100644 --- a/postgres/macos/init.sls +++ b/postgres/macos/init.sls @@ -3,7 +3,7 @@ include: {% if postgres.use_upstream_repo == 'postgresapp' %} - postgres.macos.postgresapp -{% else %} +{% elif postgres.use_upstream_repo == 'homebrew' %} - postgres.server - postgres.client {% endif %} diff --git a/postgres/macos/postgresapp.sls b/postgres/macos/postgresapp.sls index 6f5bd4c..cb4cd4f 100644 --- a/postgres/macos/postgresapp.sls +++ b/postgres/macos/postgresapp.sls @@ -27,9 +27,7 @@ pg-download-archive: interval: {{ pg.macos.dl.interval }} {% endif %} -{%- if pg.macos.postgresapp.sum %} - #Check hashstring for archive downloads - {%- if grains['saltversioninfo'] <= [2016, 11, 6] %} + {%- if pg.macos.postgresapp.sum %} pg-check-archive-hash: module.run: - name: file.check_hash @@ -40,7 +38,6 @@ pg-check-archive-hash: - require_in: - archive: pg-package-install {%- endif %} -{%- endif %} pg-package-install: macpackage.installed: @@ -56,7 +53,7 @@ pg-package-install: - file: pg-package-install - file: pg-remove-archive file.append: - - name: {{ pg.userhomes }}/{{ pg.systemuser }}/.bash_profile + - name: {{ pg.userhomes }}/{{ pg.user }}/.bash_profile - text: 'export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin' pg-remove-archive: diff --git a/postgres/osmap.yaml b/postgres/osmap.yaml index 2e1abe8..71c6344 100644 --- a/postgres/osmap.yaml +++ b/postgres/osmap.yaml @@ -33,7 +33,7 @@ RedHat: gpgcheck: 1 gpgkey: 'https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ release }}' -{% if repo.use_upstream_repo %} +{% if repo.use_upstream_repo == true %} {% set data_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %} @@ -104,7 +104,7 @@ Suse: gpgcheck: 1 gpgautoimport: True -{% if repo.use_upstream_repo %} +{% if repo.use_upstream_repo == true %} {# Pillars needed are 'use_upstream_repo: True' and 'version: n.n'. #} {# Avoid setting package names as pillars, as may corrupt postgres. #} {% set lib_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %} @@ -133,13 +133,14 @@ Suse: {% endif %} +{%- if grains.os == 'MacOS' %} +## jinja check avoids rendering noise/failure on Linux MacOS: - {# todo: homebrew postgresql #} - {% if repo.use_upstream_repo == 'homebrew' %} + {%- if repo.use_upstream_repo == 'homebrew' %} service: homebrew.mxcl.postgresql - {% elif repo.use_upstream_repo == 'postgresapp' %} + {%- elif repo.use_upstream_repo == 'postgresapp' %} service: com.postgresapp.Postgres2 - {% endif %} + {%- endif %} pkg: postgresql pkg_client: pkg_libpq_dev: @@ -152,5 +153,6 @@ MacOS: test: test -f /Users/{{ repo.user }}/Library/AppSupport/postgres_{{ repo.use_upstream_repo }}/PG_VERSION user: {{ repo.user }} group: {{ repo.group }} +{%- endif %} # vim: ft=sls diff --git a/postgres/server/init.sls b/postgres/server/init.sls index fe71435..3c26f36 100644 --- a/postgres/server/init.sls +++ b/postgres/server/init.sls @@ -4,7 +4,7 @@ {%- if postgres.bake_image %} {%- do includes.append('postgres.server.image') %} {%- endif %} -{%- if postgres.use_upstream_repo -%} +{%- if postgres.use_upstream_repo == true -%} {%- do includes.append('postgres.upstream') %} {%- endif %} @@ -18,16 +18,27 @@ include: postgresql-server: pkg.installed: - pkgs: {{ pkgs }} -{%- if postgres.use_upstream_repo %} +{%- if postgres.use_upstream_repo == true %} - refresh: True - require: - pkgrepo: postgresql-repo {%- endif %} + {%- if grains.os == 'MacOS' %} + #Register as Launchd LaunchAgent for system users + - require_in: + - file: postgresql-server + file.managed: + - name: /Library/LaunchAgents/{{ postgres.service }}.plist + - source: /usr/local/opt/postgres/{{ postgres.service }}.plist + - group: wheel + - require_in: + - service: postgresql-running + {%- else %} # Alternatives system. Make server binaries available in $PATH -{%- if 'bin_dir' in postgres and postgres.linux.altpriority %} - {%- for bin in postgres.server_bins %} - {%- set path = salt['file.join'](postgres.bin_dir, bin) %} + {%- if 'bin_dir' in postgres and postgres.linux.altpriority %} + {%- for bin in postgres.server_bins %} + {%- set path = salt['file.join'](postgres.bin_dir, bin) %} {{ bin }}: alternatives.install: @@ -40,7 +51,9 @@ postgresql-server: - require_in: - cmd: postgresql-cluster-prepared - {%- endfor %} + {%- endfor %} + {%- endif %} + {%- endif %} postgresql-cluster-prepared: @@ -59,6 +72,12 @@ postgresql-config-dir: - name: {{ postgres.conf_dir }} - user: {{ postgres.user }} - group: {{ postgres.group }} + - dir_mode: 775 + - force: True + - file_mode: 644 + - recurse: + - user + - group - makedirs: True - require: - cmd: postgresql-cluster-prepared @@ -134,7 +153,9 @@ postgresql-running: service.running: - name: {{ postgres.service }} - enable: True + {% if grains.os not in ('MacOS',) %} - reload: True + {% endif %} - watch: - file: postgresql-pg_hba diff --git a/postgres/templates/limit.maxfiles.plist b/postgres/templates/limit.maxfiles.plist index 84a6437..1b16b1b 100644 --- a/postgres/templates/limit.maxfiles.plist +++ b/postgres/templates/limit.maxfiles.plist @@ -7,7 +7,7 @@ limit.maxfiles ProgramArguments - launchctl + /bin/launchctl limit maxfiles {{ soft_limit }} diff --git a/postgres/templates/mac_shortcut.sh b/postgres/templates/mac_shortcut.sh index a156e24..4f560bf 100755 --- a/postgres/templates/mac_shortcut.sh +++ b/postgres/templates/mac_shortcut.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash -vendor=$1 +shortcutName='${1}' app="postgres.app" Source="/Applications/$app" -Destination="{{ homes }}/{{ user }}/Desktop" +Destination="{{ homes }}/{{ user }}/Desktop/${shortcutName}" /usr/bin/osascript -e "tell application \"Finder\" to make alias file to POSIX file \"$Source\" at POSIX file \"$Destination\"" diff --git a/postgres/upstream.sls b/postgres/upstream.sls index 6c3956f..cf92872 100644 --- a/postgres/upstream.sls +++ b/postgres/upstream.sls @@ -3,7 +3,7 @@ {%- if 'pkg_repo' in postgres -%} - {%- if postgres.use_upstream_repo -%} + {%- if postgres.use_upstream_repo == true -%} # Add upstream repository for your distro postgresql-repo: @@ -25,9 +25,11 @@ postgresql-repo: {%- else -%} # Notify that we don't manage this distro + {% if grains.os not in ('Windows', 'MacOS',) %} postgresql-repo: test.show_notification: - text: | PostgreSQL does not provide package repository for {{ grains['osfinger'] }} + {% endif %} {%- endif %}