From f2c13abe9c969ad66ec717f1f3515d373e8b5263 Mon Sep 17 00:00:00 2001 From: Gilou Date: Wed, 10 Oct 2018 17:49:33 +0200 Subject: [PATCH 1/3] add a profile.d script to add bin_dir to path --- postgres/defaults.yaml | 1 + postgres/templates/postgres.sh.j2 | 3 +++ postgres/upstream.sls | 12 ++++++++++++ 3 files changed, 16 insertions(+) create mode 100644 postgres/templates/postgres.sh.j2 diff --git a/postgres/defaults.yaml b/postgres/defaults.yaml index 71f473d..e2670bf 100644 --- a/postgres/defaults.yaml +++ b/postgres/defaults.yaml @@ -2,6 +2,7 @@ postgres: use_upstream_repo: True + add_path: False # add bin_dir to $PATH, if installed from repos version: '10' pkg: postgresql pkgs_extra: [] diff --git a/postgres/templates/postgres.sh.j2 b/postgres/templates/postgres.sh.j2 new file mode 100644 index 0000000..3d074fa --- /dev/null +++ b/postgres/templates/postgres.sh.j2 @@ -0,0 +1,3 @@ +if ! echo $PATH | grep -q {{ bin_dir }} ; then + export PATH=$PATH:{{ bin_dir }} +fi diff --git a/postgres/upstream.sls b/postgres/upstream.sls index 45605c4..427574d 100644 --- a/postgres/upstream.sls +++ b/postgres/upstream.sls @@ -5,6 +5,18 @@ {%- if postgres.use_upstream_repo == true -%} + {%- if postgres.add_path -%} +postgresql-profile: + file.managed: + - name: /etc/profile.d/postgres.sh + - user: root + - group: root + - mode: 644 + - template: jinja + - source: salt://postgres/templates/postgres.sh.j2 + - defaults: + bin_dir: {{ postgres.bin_dir }} + {%- endif %} # Add upstream repository for your distro postgresql-repo: pkgrepo.managed: From 728dbb64e57b06bcafc7a082d726a2bffa3261ff Mon Sep 17 00:00:00 2001 From: Gilou Date: Wed, 10 Oct 2018 18:00:28 +0200 Subject: [PATCH 2/3] add warning in sh file --- postgres/templates/postgres.sh.j2 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/postgres/templates/postgres.sh.j2 b/postgres/templates/postgres.sh.j2 index 3d074fa..fe69af7 100644 --- a/postgres/templates/postgres.sh.j2 +++ b/postgres/templates/postgres.sh.j2 @@ -1,3 +1,8 @@ +###################################################################### +# ATTENTION! Managed by SaltStack. # +# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN! # +###################################################################### + if ! echo $PATH | grep -q {{ bin_dir }} ; then export PATH=$PATH:{{ bin_dir }} fi From 5c094a05ca64b48a1732c5a746f3c8644187fdf1 Mon Sep 17 00:00:00 2001 From: Gilou Date: Thu, 11 Oct 2018 02:37:51 +0200 Subject: [PATCH 3/3] Rename setting to add_profile, add an example to explain it --- pillar.example | 3 +++ postgres/defaults.yaml | 2 +- postgres/upstream.sls | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/pillar.example b/pillar.example index 1c27387..fc17893 100644 --- a/pillar.example +++ b/pillar.example @@ -8,6 +8,9 @@ postgres: use_upstream_repo: False # Version to install from upstream repository (if upstream_repo: True) version: '10' + # Set True to add a file in /etc/profile.d adding the bin dir in $PATH + # as packages from upstream put them somewhere like /usr/pgsql-10/bin + add_profile: False # If automatic package installation fails, use `fromrepo` to specify the # upstream repo to install packages from [#133, #185] (if upstream_repo: True) fromrepo: 'jessie-pgdg' diff --git a/postgres/defaults.yaml b/postgres/defaults.yaml index e2670bf..b0d0fb5 100644 --- a/postgres/defaults.yaml +++ b/postgres/defaults.yaml @@ -2,7 +2,7 @@ postgres: use_upstream_repo: True - add_path: False # add bin_dir to $PATH, if installed from repos + add_profile: False # add bin_dir to $PATH, if installed from repos version: '10' pkg: postgresql pkgs_extra: [] diff --git a/postgres/upstream.sls b/postgres/upstream.sls index 427574d..c2d2ac7 100644 --- a/postgres/upstream.sls +++ b/postgres/upstream.sls @@ -5,7 +5,7 @@ {%- if postgres.use_upstream_repo == true -%} - {%- if postgres.add_path -%} + {%- if postgres.add_profile -%} postgresql-profile: file.managed: - name: /etc/profile.d/postgres.sh