Tidyup alternatives system priority hardcoding

This commit is contained in:
Noel McLoughin 2018-01-14 16:12:17 +00:00 committed by noelmcloughlin
parent a87ccfb0ed
commit db90890184
5 changed files with 25 additions and 29 deletions

View file

@ -14,6 +14,10 @@ postgres:
- postgresql-contrib - postgresql-contrib
- postgresql-plpython - postgresql-plpython
#'Alternatives system' priority incremental. 0 disables feature.
linux:
altpriority: 30
# Append the lines under this item to your postgresql.conf file. # Append the lines under this item to your postgresql.conf file.
# Pay attention to indent exactly with 4 spaces for all lines. # Pay attention to indent exactly with 4 spaces for all lines.
postgresconf: | postgresconf: |

View file

@ -8,14 +8,11 @@
{%- endfor %} {%- endfor %}
{%- if postgres.use_upstream_repo %} {%- if postgres.use_upstream_repo %}
include: include:
- postgres.upstream - postgres.upstream
{%- endif %} {%- endif %}
# Install PostgreSQL client and libraries # Install PostgreSQL client and libraries
postgresql-client-libs: postgresql-client-libs:
pkg.installed: pkg.installed:
- pkgs: {{ pkgs }} - pkgs: {{ pkgs }}
@ -25,23 +22,19 @@ postgresql-client-libs:
- pkgrepo: postgresql-repo - pkgrepo: postgresql-repo
{%- endif %} {%- endif %}
{%- if 'bin_dir' in postgres %} # Alternatives system. Make client binaries available in $PATH
{%- if 'bin_dir' in postgres and postgres.linux.altpriority %}
# Make client binaries available in $PATH {%- for bin in postgres.client_bins %}
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
{%- for bin in postgres.client_bins %}
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
{{ bin }}: {{ bin }}:
alternatives.install: alternatives.install:
- link: {{ salt['file.join']('/usr/bin', bin) }} - link: {{ salt['file.join']('/usr/bin', bin) }}
- path: {{ path }} - path: {{ path }}
- priority: 30 - priority: {{ postgres.linux.altpriority }}
- onlyif: test -f {{ path }} - onlyif: test -f {{ path }}
- require: - require:
- pkg: postgresql-client-libs - pkg: postgresql-client-libs
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}

View file

@ -41,3 +41,7 @@ postgres:
databases: {} databases: {}
schemas: {} schemas: {}
extensions: {} extensions: {}
linux:
#Alternatives system are disabled by a 'altpriority=0' pillar.
altpriority:

View file

@ -46,7 +46,11 @@ RedHat:
command: initdb --pgdata='{{ data_dir }}' command: initdb --pgdata='{{ data_dir }}'
test: test -f '{{ data_dir }}/PG_VERSION' test: test -f '{{ data_dir }}/PG_VERSION'
# Directory containing PostgreSQL client executables # Alternatives system
linux:
altpriority: 30
# directory containing PostgreSQL client executables
bin_dir: /usr/pgsql-{{ repo.version }}/bin bin_dir: /usr/pgsql-{{ repo.version }}/bin
client_bins: client_bins:
- clusterdb - clusterdb

View file

@ -9,16 +9,12 @@
{%- endif %} {%- endif %}
{%- if includes -%} {%- if includes -%}
include: include:
{{ includes|yaml(false)|indent(2) }} {{ includes|yaml(false)|indent(2) }}
{%- endif %} {%- endif %}
{%- set pkgs = [postgres.pkg] + postgres.pkgs_extra %} {%- set pkgs = [postgres.pkg] + postgres.pkgs_extra %}
# Install, configure and start PostgreSQL server # Install, configure and start PostgreSQL server
postgresql-server: postgresql-server:
pkg.installed: pkg.installed:
- pkgs: {{ pkgs }} - pkgs: {{ pkgs }}
@ -28,27 +24,23 @@ postgresql-server:
- pkgrepo: postgresql-repo - pkgrepo: postgresql-repo
{%- endif %} {%- endif %}
{%- if 'bin_dir' in postgres %} # Alternatives system. Make server binaries available in $PATH
{%- if 'bin_dir' in postgres and postgres.linux.altpriority %}
# Make server binaries available in $PATH {%- for bin in postgres.server_bins %}
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
{%- for bin in postgres.server_bins %}
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
{{ bin }}: {{ bin }}:
alternatives.install: alternatives.install:
- link: {{ salt['file.join']('/usr/bin', bin) }} - link: {{ salt['file.join']('/usr/bin', bin) }}
- path: {{ path }} - path: {{ path }}
- priority: 30 - priority: {{ postgres.linux.altpriority }}
- onlyif: test -f {{ path }} - onlyif: test -f {{ path }}
- require: - require:
- pkg: postgresql-server - pkg: postgresql-server
- require_in: - require_in:
- cmd: postgresql-cluster-prepared - cmd: postgresql-cluster-prepared
{%- endfor %} {%- endfor %}
{%- endif %} {%- endif %}
postgresql-cluster-prepared: postgresql-cluster-prepared:
@ -138,7 +130,6 @@ postgresql-tablespace-dir-{{ name }}:
{%- if not postgres.bake_image %} {%- if not postgres.bake_image %}
# Start PostgreSQL server using OS init # Start PostgreSQL server using OS init
postgresql-running: postgresql-running:
service.running: service.running:
- name: {{ postgres.service }} - name: {{ postgres.service }}