Trying to run command as ubuntu user

Currently I am provisioning a VM with an ansible script that preferably mustn’t be changed. This ansible script uses the ubuntu user as the working user so when I try to run tests I need to run them as the ubuntu user how ever when I try to run the su - ubuntu command the job just hangs as if it is waiting for a user input or something. When I ssh onto the box I can switch user no problem. If anyone can help me run steps as ubuntu instead of circleci that would be awesome!

I think you’re going to need to provide a reproduction repo of some kind or at least a paste of the CCI config and script in question. There’s too many variables that could be affecting you to be able to provide much help.

At the very least su - ubuntu doesn’t work non-interactively (i.e. from a script), AFAIK.

Depending on what you’re actually trying to do simply switching to sudo -u ubuntu ansible … may be good enough.

Of course your actual CCI config plays a big role here. For instance, if you’re using a typical container executor then you can often switch to the right user by just specifying user: ubuntu in the executor configuration.