adding a custom dir to a users (not global) PATH via Ansbile

58 views
Skip to first unread message

dulh...@mailbox.org

unread,
Nov 29, 2021, 5:05:38 AM11/29/21
to ansible...@googlegroups.com
I am trying my luck with installing barman as barman user (non-root) via ansible

At the end I need to adust the PATH of the barman user and have managed to add the relevant location (/opt/barman/.local/bin) to the global PATH with the TASK below (from a comment in https://www.jeffgeerling.com/blog/2017/add-path-global-path-ansible)

    - name: Add another bin dir to system-wide $PATH.
      copy:
        dest: /etc/profile.d/custom-path.sh
        content: 'PATH=$PATH:{{ my_custom_path_var }}'

this works as intendet. I would, however, prefer to only address the PATH of the barman user.
I treid to:
  1. create a .profile.d directory in my barman users home (/opt/barman) and
  2. send the script there instead the global /etc/profile.d ?
maybe a ~.profile is needed to makes this work? but how would that have to look like?

Dick Visser

unread,
Nov 29, 2021, 5:24:47 AM11/29/21
to ansible...@googlegroups.com
Hi

Your question seems to be around "installing barman" (no idea what that is), and while doing that you run into some generic system administration issue.
Ansible is not really relevant to both the issues. It's used to automate things, but that implies that you already know how to do those things.
The recommended approach is to first make "installing barman" work without ansible.
And when that was successful, automate the required steps using ansible.



--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2090931952.382712.1638180320671%40office.mailbox.org.


--
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

alex...@gmail.com

unread,
Nov 29, 2021, 12:20:12 PM11/29/21
to Ansible Project
Traverse /home and for each user:
edit:
  ~/.bashrc
with:
 export PATH="SOMETHING":$PATH"

Nico Kadel-Garcia

unread,
Dec 1, 2021, 7:26:51 AM12/1/21
to Ansible Project
On Monday, November 29, 2021 at 12:20:12 PM UTC-5 alex...@gmail.com wrote:
Traverse /home and for each user:
edit:
  ~/.bashrc
with:
 export PATH="SOMETHING":$PATH"


This way lies madness, and a stack of security issues when someone or some process sticks alternative binaries or scripts for "ls" or "sh" in SOMETHING/sh. Also, as PATH becomes longer and longer from repeated such exercises, it can exceed the maximum PATH. It should be added to cautiously.

"Traverse /home" is also a non-starter in environments where home directories are auto-mounted or don't live in /home/ for particular users, and tools like the "barman"  software for PostgreSQL backups have their own fascinating habit of shoving components in $HOME/ that need to be completed for each user.

May I suggest thoughtfully activating such changes only as needed for particular users, perhaps as part of the "barman" setup for those users?

 

dulh...@mailbox.org

unread,
Dec 1, 2021, 8:19:19 AM12/1/21
to ansible...@googlegroups.com
thx @alex & Nico,

I did something quite similar (for one particular user).
As I am pushing a .bashrc up to the target anyway at some point I added my PATH in the same manner you suggets here via the edit Module.


--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages