user change

user change form root to new_user at the time of playbook running

like a user created and one service will run under root and 2 nd service will run as new_user

You can use
become: yes
become_user: your user
become_method: sudo/su (default sudo)

Br,
Md Asiful Haque

Here is the documentation for switching user or privilege escalation

Br,

Md Asiful Haque

https://docs.ansible.com/ansible/latest/user_guide/become.html

Br,

Md Asiful Haque

same permission issue

HI Rajeeb,

Is it possible to share the problem area of you playbook?

I can share the scenario.
I want to create a user then I want to install a docker in that user.

Hi Rajeeb,

If i understand correctly then the darth_vader(new user) will be used to execute docker command right ?

docker can be installed with root user or sudo user. However, it can be run using non-sudo user as well. If user darth_vader belongs to non-sudo group then install the docker using sudo or root user and add user darth_vader to docker group.

source: https://askubuntu.com/questions/477551/how-can-i-use-docker-without-sudo