Skip to content

W/A hardcoding of debian alternatives priority #177

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ postgres:
- postgresql-contrib
- postgresql-plpython


#'Alternatives system' priority incremental. 0 disables feature.
linux:
altpriority: 30

# POSTGRES
# Append the lines under this item to your postgresql.conf file.
# Pay attention to indent exactly with 4 spaces for all lines.
Expand Down
19 changes: 6 additions & 13 deletions postgres/client.sls
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,11 @@
{%- endfor %}

{%- if postgres.use_upstream_repo %}

include:
- postgres.upstream

{%- endif %}

# Install PostgreSQL client and libraries

postgresql-client-libs:
pkg.installed:
- pkgs: {{ pkgs }}
Expand All @@ -25,23 +22,19 @@ postgresql-client-libs:
- pkgrepo: postgresql-repo
{%- endif %}

{%- if 'bin_dir' in postgres %}

# Make client binaries available in $PATH

{%- for bin in postgres.client_bins %}

{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
# Alternatives system. Make client binaries available in $PATH
{%- if 'bin_dir' in postgres and postgres.linux.altpriority %}
{%- for bin in postgres.client_bins %}
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}

{{ bin }}:
alternatives.install:
- link: {{ salt['file.join']('/usr/bin', bin) }}
- path: {{ path }}
- priority: 30
- priority: {{ postgres.linux.altpriority }}
- onlyif: test -f {{ path }}
- require:
- pkg: postgresql-client-libs

{%- endfor %}

{%- endfor %}
{%- endif %}
4 changes: 4 additions & 0 deletions postgres/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,7 @@ postgres:
databases: {}
schemas: {}
extensions: {}

linux:
#Alternatives system are disabled by a 'altpriority=0' pillar.
altpriority:
6 changes: 5 additions & 1 deletion postgres/osmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,11 @@ RedHat:
command: initdb --pgdata='{{ data_dir }}'
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
client_bins:
- clusterdb
Expand Down
21 changes: 6 additions & 15 deletions postgres/server/init.sls
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,12 @@
{%- endif %}

{%- if includes -%}

include:
{{ includes|yaml(false)|indent(2) }}

{%- endif %}

{%- set pkgs = [postgres.pkg] + postgres.pkgs_extra %}

# Install, configure and start PostgreSQL server

postgresql-server:
pkg.installed:
- pkgs: {{ pkgs }}
Expand All @@ -28,27 +24,23 @@ postgresql-server:
- pkgrepo: postgresql-repo
{%- endif %}

{%- if 'bin_dir' in postgres %}

# Make server binaries available in $PATH

{%- for bin in postgres.server_bins %}

{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
# 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) %}

{{ bin }}:
alternatives.install:
- link: {{ salt['file.join']('/usr/bin', bin) }}
- path: {{ path }}
- priority: 30
- priority: {{ postgres.linux.altpriority }}
- onlyif: test -f {{ path }}
- require:
- pkg: postgresql-server
- require_in:
- cmd: postgresql-cluster-prepared

{%- endfor %}

{%- endfor %}
{%- endif %}

postgresql-cluster-prepared:
Expand Down Expand Up @@ -138,7 +130,6 @@ postgresql-tablespace-dir-{{ name }}:
{%- if not postgres.bake_image %}

# Start PostgreSQL server using OS init

postgresql-running:
service.running:
- name: {{ postgres.service }}
Expand Down