ansible-role-golang icon indicating copy to clipboard operation
ansible-role-golang copied to clipboard

Not working when become: yes

Open kristijorgji opened this issue 4 years ago • 2 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

kristijorgji avatar Jun 19 '21 14:06 kristijorgji

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.

sebix avatar Aug 22 '22 15:08 sebix

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.

electronick avatar Jun 13 '23 18:06 electronick