Homebrew Postgres on MacOS

This commit is contained in:
noelmcloughlin
2018-03-08 12:30:25 +00:00
parent 1e527c4b91
commit a34a4c270c
12 changed files with 60 additions and 38 deletions

View File

@@ -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