Skip to content

Commit d5dcac9

Browse files
author
Denys Havrysh
committed
RedHat: make client binaries available in $PATH
1 parent ea8c88c commit d5dcac9

File tree

5 files changed

+73
-21
lines changed

5 files changed

+73
-21
lines changed

postgres/client.sls

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,45 @@
1-
{% from "postgres/map.jinja" import postgres with context %}
1+
{%- from "postgres/map.jinja" import postgres with context -%}
2+
3+
{%- set pkgs = [] %}
4+
{%- for pkg in (postgres.pkg_client, postgres.pkg_libpq_dev) %}
5+
{%- if pkg %}
6+
{%- do pkgs.append(pkg) %}
7+
{%- endif %}
8+
{%- endfor -%}
9+
10+
{%- if postgres.use_upstream_repo %}
211
3-
{% if postgres.use_upstream_repo %}
412
include:
513
- postgres.upstream
6-
{% endif %}
714
8-
install-postgresql-client:
15+
{%- endif %}
16+
17+
postgresql-client-libs:
918
pkg.installed:
10-
- name: {{ postgres.pkg_client }}
11-
- refresh: {{ postgres.use_upstream_repo }}
12-
{% if postgres.use_upstream_repo %}
19+
- pkgs: {{ pkgs }}
20+
{%- if postgres.use_upstream_repo %}
21+
- refresh: True
1322
- require:
14-
- pkgrepo: install-postgresql-repo
23+
- pkgrepo: postgresql-repo
1524
{%- endif %}
1625
17-
{% if postgres.pkg_libpq_dev %}
18-
install-postgres-libpq-dev:
19-
pkg.installed:
20-
- name: {{ postgres.pkg_libpq_dev }}
21-
{% endif %}
26+
{%- if 'bin_dir' in postgres %}
27+
28+
# Make client binaries available in $PATH
29+
30+
{%- for bin in postgres.client_bins %}
31+
32+
{%- set path = salt['file.join'](postgres.bin_dir, bin) %}
33+
34+
{{ bin }}:
35+
alternatives.install:
36+
- link: {{ salt['file.join']('/usr/bin', bin) }}
37+
- path: {{ path }}
38+
- priority: 30
39+
- onlyif: test -f {{ path }}
40+
- require:
41+
- pkg: postgresql-client-libs
42+
43+
{%- endfor %}
44+
45+
{%- endif %}

postgres/defaults.yaml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,30 @@ postgres:
3939
command: service postgresql initdb
4040
test: test -f /var/lib/pgsql/data/PG_VERSION
4141
env: {}
42+
43+
# Client executables list
44+
client_bins:
45+
- clusterdb
46+
- createdb
47+
- createlang
48+
- createuser
49+
- dropdb
50+
- droplang
51+
- dropuser
52+
- pg_archivecleanup
53+
- pg_basebackup
54+
- pg_config
55+
- pg_dump
56+
- pg_dumpall
57+
- pg_isready
58+
- pg_receivexlog
59+
- pg_restore
60+
- pg_rewind
61+
- pg_test_fsync
62+
- pg_test_timing
63+
- pg_upgrade
64+
- pg_xlogdump
65+
- pgbench
66+
- psql
67+
- reindexdb
68+
- vacuumdb

postgres/init.sls

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ include:
1212

1313
### Installation states
1414

15-
postgresql-installed:
15+
postgresql-server:
1616
pkg.installed:
1717
- name: {{ postgres.pkg }}
18-
- refresh: {{ postgres.use_upstream_repo }}
19-
{% if postgres.use_upstream_repo %}
18+
{%- if postgres.use_upstream_repo %}
19+
- refresh: True
2020
- require:
21-
- pkgrepo: install-postgresql-repo
21+
- pkgrepo: postgresql-repo
2222
{%- endif %}
2323

2424
# make sure the data directory and contents have been initialized
@@ -31,7 +31,7 @@ postgresql-cluster-prepared:
3131
- unless:
3232
- {{ postgres.prepare_cluster.test }}
3333
- require:
34-
- pkg: postgresql-installed
34+
- pkg: postgresql-server
3535

3636
postgresql-config-dir:
3737
file.directory:

postgres/osmap.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ RedHat:
3939

4040
pkg: postgresql{{ release }}-server
4141
pkg_client: postgresql{{ release }}
42+
bin_dir: /usr/pgsql-{{ repo.version }}/bin
4243
conf_dir: /var/lib/pgsql/{{ repo.version }}/data
4344
service: postgresql-{{ repo.version }}
4445

postgres/upstream.sls

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
{%- if postgres.use_upstream_repo -%}
77
88
# Add upstream repository for your distro
9-
install-postgresql-repo:
9+
postgresql-repo:
1010
pkgrepo.managed:
1111
{{- format_kwargs(postgres.pkg_repo) }}
1212
1313
{%- else -%}
1414
1515
# Remove the repo configuration (and GnuPG key) as requested
16-
remove-postgresql-repo:
16+
postgresql-repo:
1717
pkgrepo.absent:
1818
- name: {{ postgres.pkg_repo.name }}
1919
{%- if 'pkg_repo_keyid' in postgres %}
@@ -25,7 +25,7 @@ remove-postgresql-repo:
2525
{%- else -%}
2626
2727
# Notify that we don't manage this distro
28-
install-postgresql-repo:
28+
postgresql-repo:
2929
test.show_notification:
3030
- text: |
3131
PostgreSQL does not provide package repository for {{ grains['osfinger'] }}

0 commit comments

Comments
 (0)