How to switch to the application account?

Don’t know if i have to write this subject in french or english so i go with english (sorry for my english rough spelling)

I have a playbook that can only be run with the application account.

The paths are hard-coded (for the moment) but I would like to use a variable to make this dynamic.
but unfornately don’t still know how to do ?
The application account looks like something like this:


The playbook is simple and looks like something like this:

The playbook looks something like this.
- name: Compress directory /abcpzzz/path/to/foo/ into /path/to/foo.tgz
     path: /abcpzzz/path/to/foo
     dest: /abcpzzz/path/to/foo.tgz

How to call all the path properly in a variable ?

Sorry for everyone who will read my post.
i forgot to start by i simple “hello” and finish as well by i simple “thanks”

Have you referenced Using Variables — Ansible Documentation ?

Thanks for your response.
Of course i have referred to the ansible doc, but my real probem is not how to use a variable is how select the right application account (which is in /etc/passwd) to switch automatically to application account when playbook log on the server the run the play.

If I am understanding you correctly, maybe you need to use host variables in your inventory - How to build your inventory — Ansible Documentation

Or else read /etc/passwd in one task, and then set become_user and/or other variables based on what you see in the file?

If neither of these help, then you may need to expand on what you are doing - provide a more detailed playbook, provide the expected and actual results, maybe provide how you manually do it … It’s a bit unclear (to me at least) on what the ultimate goal is…

i’m talking and asking about how to use “ansible_env.HOME” in the playbook to Set the remote environment

Again, please provide more information - full playbooks, results using -vvv, expected/actual results, results running manually, etc., so that people can provide more feedback.

If you are talking about using setting the remote Environment Variables within Ansible, please refer to Setting the remote environment — Ansible Documentation