Not working when become: yes
kristijorgji opened this issue · comments
The role is installing fine go binary after extracting to specified location.
Issue is that after I ssh into remote machine, and sudo su
, go command is not available as root.
I can solve that by running manually in terminal
source /etc/profile.d/golang.sh
# go now will work
ansible --version ansible 2.10.10
Why is this happening and not working for root ?
When I ssh at machine ssh -i key ubuntu@someip" as ubuntu user (in ec2) i can run go commad, profile.d is loaded, but after
sudo su` that does not work as root.
Then all other ansible scripts fail that use root user to use installed go for building code
Without knowing what operating system you are using and which shell and the contents of various files, it is hard to tell, what is different on your server for the root user.
But that is unrelated to this ansible role.
The solution is to use sudo su -
instead of sudo su
or add source /etc/profile.d/golang.sh
to ~/.bashrc
of the user you're switching to as /etc/profile.d/* loads only for login shells.