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

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?

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.

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?

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.