Homebrew Postgres on MacOS
This commit is contained in:
@@ -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
|
* ``True`` (default): adds the upstream repository to install packages from
|
||||||
* ``False``: makes sure that the repository configuration is absent
|
* ``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
|
The ``postgres:version`` Pillar controls which version of the PostgreSQL packages should be
|
||||||
installed from the upstream Linux repository. Defaults to ``9.5``.
|
installed from the upstream Linux repository. Defaults to ``9.5``.
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ postgres:
|
|||||||
version: '9.6'
|
version: '9.6'
|
||||||
|
|
||||||
### MACOS
|
### MACOS
|
||||||
# Set to 'postgresapp' to install that upstream MacOS package
|
# Set to 'postgresapp' OR 'homebrew' for MacOS
|
||||||
#use_upstream_repo: 'postgresapp'
|
#use_upstream_repo: 'postgresapp'
|
||||||
|
#use_upstream_repo: 'homebrew'
|
||||||
|
|
||||||
# PACKAGE
|
# PACKAGE
|
||||||
# These pillars are typically never required.
|
# These pillars are typically never required.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
|
||||||
{%- if postgres.use_upstream_repo %}
|
{%- if postgres.use_upstream_repo == true %}
|
||||||
include:
|
include:
|
||||||
- postgres.upstream
|
- postgres.upstream
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
@@ -16,7 +16,7 @@ include:
|
|||||||
postgresql-client-libs:
|
postgresql-client-libs:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
- pkgs: {{ pkgs }}
|
- pkgs: {{ pkgs }}
|
||||||
{%- if postgres.use_upstream_repo %}
|
{%- if postgres.use_upstream_repo == true %}
|
||||||
- refresh: True
|
- refresh: True
|
||||||
- require:
|
- require:
|
||||||
- pkgrepo: postgresql-repo
|
- pkgrepo: postgresql-repo
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
#}
|
#}
|
||||||
|
|
||||||
{# use upstream version if configured #}
|
{# use upstream version if configured #}
|
||||||
{% if repo.use_upstream_repo %}
|
{% if repo.use_upstream_repo == true %}
|
||||||
{% set version = repo.version %}
|
{% set version = repo.version %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
#}
|
#}
|
||||||
|
|
||||||
{# use upstream version if configured #}
|
{# use upstream version if configured #}
|
||||||
{% if repo.use_upstream_repo %}
|
{% if repo.use_upstream_repo == true %}
|
||||||
{% set version = repo.version %}
|
{% set version = repo.version %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|||||||
@@ -29,20 +29,17 @@ postgres_maxfiles_limits_conf:
|
|||||||
- context:
|
- context:
|
||||||
soft_limit: {{ postgres.limits.soft or postgres.limits.hard }}
|
soft_limit: {{ postgres.limits.soft or postgres.limits.hard }}
|
||||||
hard_limit: {{ postgres.limits.hard or postgres.limits.soft }}
|
hard_limit: {{ postgres.limits.hard or postgres.limits.soft }}
|
||||||
- group: wheel
|
- group: {{ postgres.group }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# MacOS Shortcut for system user
|
{% if postgres.use_upstream_repo == 'postgresapp' %}
|
||||||
{% if postgres.systemuser|lower not in (None, '',) %}
|
# Shortcut for PostgresApp
|
||||||
|
|
||||||
postgres-desktop-shortcut-clean:
|
postgres-desktop-shortcut-clean:
|
||||||
file.absent:
|
file.absent:
|
||||||
- name: '{{ postgres.userhomes }}/{{ postgres.systemuser }}/Desktop/postgres'
|
- name: '{{ postgres.userhomes }}/{{ postgres.user }}/Desktop/Postgres ({{ postgres.use_upstream_repo }})'
|
||||||
- require_in:
|
- require_in:
|
||||||
- file: postgres-desktop-shortcut-add
|
- file: postgres-desktop-shortcut-add
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
postgres-desktop-shortcut-add:
|
postgres-desktop-shortcut-add:
|
||||||
file.managed:
|
file.managed:
|
||||||
- name: /tmp/mac_shortcut.sh
|
- name: /tmp/mac_shortcut.sh
|
||||||
@@ -50,12 +47,13 @@ postgres-desktop-shortcut-add:
|
|||||||
- mode: 755
|
- mode: 755
|
||||||
- template: jinja
|
- template: jinja
|
||||||
- context:
|
- context:
|
||||||
user: {{ postgres.systemuser }}
|
user: {{ postgres.user }}
|
||||||
homes: {{ postgres.userhomes }}
|
homes: {{ postgres.userhomes }}
|
||||||
cmd.run:
|
cmd.run:
|
||||||
- name: /tmp/mac_shortcut.sh {{ postgres.use_upstream_repo }}
|
- name: '/tmp/mac_shortcut.sh "Postgres ({{ postgres.use_upstream_repo }})"'
|
||||||
- runas: {{ postgres.systemuser }}
|
- runas: {{ postgres.user }}
|
||||||
- require:
|
- require:
|
||||||
- file: postgres-desktop-shortcut-add
|
- file: postgres-desktop-shortcut-add
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
include:
|
include:
|
||||||
{% if postgres.use_upstream_repo == 'postgresapp' %}
|
{% if postgres.use_upstream_repo == 'postgresapp' %}
|
||||||
- postgres.macos.postgresapp
|
- postgres.macos.postgresapp
|
||||||
{% else %}
|
{% elif postgres.use_upstream_repo == 'homebrew' %}
|
||||||
- postgres.server
|
- postgres.server
|
||||||
- postgres.client
|
- postgres.client
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ pg-download-archive:
|
|||||||
interval: {{ pg.macos.dl.interval }}
|
interval: {{ pg.macos.dl.interval }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- if pg.macos.postgresapp.sum %}
|
{%- if pg.macos.postgresapp.sum %}
|
||||||
#Check hashstring for archive downloads
|
|
||||||
{%- if grains['saltversioninfo'] <= [2016, 11, 6] %}
|
|
||||||
pg-check-archive-hash:
|
pg-check-archive-hash:
|
||||||
module.run:
|
module.run:
|
||||||
- name: file.check_hash
|
- name: file.check_hash
|
||||||
@@ -40,7 +38,6 @@ pg-check-archive-hash:
|
|||||||
- require_in:
|
- require_in:
|
||||||
- archive: pg-package-install
|
- archive: pg-package-install
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- endif %}
|
|
||||||
|
|
||||||
pg-package-install:
|
pg-package-install:
|
||||||
macpackage.installed:
|
macpackage.installed:
|
||||||
@@ -56,7 +53,7 @@ pg-package-install:
|
|||||||
- file: pg-package-install
|
- file: pg-package-install
|
||||||
- file: pg-remove-archive
|
- file: pg-remove-archive
|
||||||
file.append:
|
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'
|
- text: 'export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/latest/bin'
|
||||||
|
|
||||||
pg-remove-archive:
|
pg-remove-archive:
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ RedHat:
|
|||||||
gpgcheck: 1
|
gpgcheck: 1
|
||||||
gpgkey: 'https://download.postgresql.org/pub/repos/yum/RPM-GPG-KEY-PGDG-{{ release }}'
|
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' %}
|
{% set data_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ Suse:
|
|||||||
gpgcheck: 1
|
gpgcheck: 1
|
||||||
gpgautoimport: True
|
gpgautoimport: True
|
||||||
|
|
||||||
{% if repo.use_upstream_repo %}
|
{% if repo.use_upstream_repo == true %}
|
||||||
{# Pillars needed are 'use_upstream_repo: True' and 'version: n.n'. #}
|
{# Pillars needed are 'use_upstream_repo: True' and 'version: n.n'. #}
|
||||||
{# Avoid setting package names as pillars, as may corrupt postgres. #}
|
{# Avoid setting package names as pillars, as may corrupt postgres. #}
|
||||||
{% set lib_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %}
|
{% set lib_dir = '/var/lib/pgsql/' ~ repo.version ~ '/data' %}
|
||||||
@@ -133,13 +133,14 @@ Suse:
|
|||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{%- if grains.os == 'MacOS' %}
|
||||||
|
## jinja check avoids rendering noise/failure on Linux
|
||||||
MacOS:
|
MacOS:
|
||||||
{# todo: homebrew postgresql #}
|
{%- if repo.use_upstream_repo == 'homebrew' %}
|
||||||
{% if repo.use_upstream_repo == 'homebrew' %}
|
|
||||||
service: homebrew.mxcl.postgresql
|
service: homebrew.mxcl.postgresql
|
||||||
{% elif repo.use_upstream_repo == 'postgresapp' %}
|
{%- elif repo.use_upstream_repo == 'postgresapp' %}
|
||||||
service: com.postgresapp.Postgres2
|
service: com.postgresapp.Postgres2
|
||||||
{% endif %}
|
{%- endif %}
|
||||||
pkg: postgresql
|
pkg: postgresql
|
||||||
pkg_client:
|
pkg_client:
|
||||||
pkg_libpq_dev:
|
pkg_libpq_dev:
|
||||||
@@ -152,5 +153,6 @@ MacOS:
|
|||||||
test: test -f /Users/{{ repo.user }}/Library/AppSupport/postgres_{{ repo.use_upstream_repo }}/PG_VERSION
|
test: test -f /Users/{{ repo.user }}/Library/AppSupport/postgres_{{ repo.use_upstream_repo }}/PG_VERSION
|
||||||
user: {{ repo.user }}
|
user: {{ repo.user }}
|
||||||
group: {{ repo.group }}
|
group: {{ repo.group }}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
# vim: ft=sls
|
# vim: ft=sls
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
{%- if postgres.bake_image %}
|
{%- if postgres.bake_image %}
|
||||||
{%- do includes.append('postgres.server.image') %}
|
{%- do includes.append('postgres.server.image') %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
{%- if postgres.use_upstream_repo -%}
|
{%- if postgres.use_upstream_repo == true -%}
|
||||||
{%- do includes.append('postgres.upstream') %}
|
{%- do includes.append('postgres.upstream') %}
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
@@ -18,14 +18,25 @@ include:
|
|||||||
postgresql-server:
|
postgresql-server:
|
||||||
pkg.installed:
|
pkg.installed:
|
||||||
- pkgs: {{ pkgs }}
|
- pkgs: {{ pkgs }}
|
||||||
{%- if postgres.use_upstream_repo %}
|
{%- if postgres.use_upstream_repo == true %}
|
||||||
- refresh: True
|
- refresh: True
|
||||||
- require:
|
- require:
|
||||||
- pkgrepo: postgresql-repo
|
- pkgrepo: postgresql-repo
|
||||||
{%- endif %}
|
{%- 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
|
# Alternatives system. Make server binaries available in $PATH
|
||||||
{%- if 'bin_dir' in postgres and postgres.linux.altpriority %}
|
{%- if 'bin_dir' in postgres and postgres.linux.altpriority %}
|
||||||
{%- for bin in postgres.server_bins %}
|
{%- for bin in postgres.server_bins %}
|
||||||
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
|
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
|
||||||
|
|
||||||
@@ -41,6 +52,8 @@ postgresql-server:
|
|||||||
- cmd: postgresql-cluster-prepared
|
- cmd: postgresql-cluster-prepared
|
||||||
|
|
||||||
{%- endfor %}
|
{%- endfor %}
|
||||||
|
{%- endif %}
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|
||||||
postgresql-cluster-prepared:
|
postgresql-cluster-prepared:
|
||||||
@@ -59,6 +72,12 @@ postgresql-config-dir:
|
|||||||
- name: {{ postgres.conf_dir }}
|
- name: {{ postgres.conf_dir }}
|
||||||
- user: {{ postgres.user }}
|
- user: {{ postgres.user }}
|
||||||
- group: {{ postgres.group }}
|
- group: {{ postgres.group }}
|
||||||
|
- dir_mode: 775
|
||||||
|
- force: True
|
||||||
|
- file_mode: 644
|
||||||
|
- recurse:
|
||||||
|
- user
|
||||||
|
- group
|
||||||
- makedirs: True
|
- makedirs: True
|
||||||
- require:
|
- require:
|
||||||
- cmd: postgresql-cluster-prepared
|
- cmd: postgresql-cluster-prepared
|
||||||
@@ -134,7 +153,9 @@ postgresql-running:
|
|||||||
service.running:
|
service.running:
|
||||||
- name: {{ postgres.service }}
|
- name: {{ postgres.service }}
|
||||||
- enable: True
|
- enable: True
|
||||||
|
{% if grains.os not in ('MacOS',) %}
|
||||||
- reload: True
|
- reload: True
|
||||||
|
{% endif %}
|
||||||
- watch:
|
- watch:
|
||||||
- file: postgresql-pg_hba
|
- file: postgresql-pg_hba
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<string>limit.maxfiles</string>
|
<string>limit.maxfiles</string>
|
||||||
<key>ProgramArguments</key>
|
<key>ProgramArguments</key>
|
||||||
<array>
|
<array>
|
||||||
<string>launchctl</string>
|
<string>/bin/launchctl</string>
|
||||||
<string>limit</string>
|
<string>limit</string>
|
||||||
<string>maxfiles</string>
|
<string>maxfiles</string>
|
||||||
<string>{{ soft_limit }}</string>
|
<string>{{ soft_limit }}</string>
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
vendor=$1
|
shortcutName='${1}'
|
||||||
app="postgres.app"
|
app="postgres.app"
|
||||||
Source="/Applications/$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\""
|
/usr/bin/osascript -e "tell application \"Finder\" to make alias file to POSIX file \"$Source\" at POSIX file \"$Destination\""
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
{%- if 'pkg_repo' in postgres -%}
|
{%- if 'pkg_repo' in postgres -%}
|
||||||
|
|
||||||
{%- if postgres.use_upstream_repo -%}
|
{%- if postgres.use_upstream_repo == true -%}
|
||||||
|
|
||||||
# Add upstream repository for your distro
|
# Add upstream repository for your distro
|
||||||
postgresql-repo:
|
postgresql-repo:
|
||||||
@@ -25,9 +25,11 @@ postgresql-repo:
|
|||||||
{%- else -%}
|
{%- else -%}
|
||||||
|
|
||||||
# Notify that we don't manage this distro
|
# Notify that we don't manage this distro
|
||||||
|
{% if grains.os not in ('Windows', 'MacOS',) %}
|
||||||
postgresql-repo:
|
postgresql-repo:
|
||||||
test.show_notification:
|
test.show_notification:
|
||||||
- text: |
|
- text: |
|
||||||
PostgreSQL does not provide package repository for {{ grains['osfinger'] }}
|
PostgreSQL does not provide package repository for {{ grains['osfinger'] }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{%- endif %}
|
{%- endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user