ads' corner

Run Ansible tasks as different remote user

Had a somewhat curious situation: need to run a task in Ansible in different user accounts, but I don’t have sudo or su access, only ssh access for every account. Took me a moment to figure out how to do that.


Ansible and LXC Containers

LXC is one of many available containerization solutions for Linux. Ansible has basic support for LXC integrated, which is fine if you do not intend to do much inside of the container (aka: fire & forget). My goal however is to start a full flavored container, and manage this container with Ansible as well. That’s where things get a bit tricky, and looking around I couldn’t find much documentation how to do this.

This posting describes my approach.


sudo: sorry, you must have a tty to run sudo

It took me a while to find out, why this backup script would not start. Finally, I found this error message: sudo: sorry, you must have a tty to run sudo. The sudo call is required to execute clustat and find out, which machine is the current master.

sudo is configured to execute clustat without password and works fine on the command line - so what’s wrong here?