shell executes on the remote machine, it does not look for any
resources 'local' to the controller, the 'working directory' depends
on login/become setup used on the target machine (normally
/home/<remote_user|become_user>.
Your subject line has a question in it, but the body does not. Is your question “Where are scripts executed?” If that is your question then yes, you’re correct, it should be the home directory of the user you logged into the remote server with. You can see by doing something like
`
ansible servera -m shell -a “ls”-u username
`
This will print the contents of the working directory when a user logs in. Try it with the become options to see what the result is. You can use an absolute path to call a script. Or use the “chdir” option for shell, something like