ansible_user_id has incorrect value when overriding playbook sudo value in a task

Hi All,

Perhaps I don’t understand the ansible_user_id variable, but consider the following cases:

https://gist.github.com/ramondelafuente/9819526

When you set a single task to sudo:no when the playbook has sudo: yes (or the other way around), ansibile_ssh_user has an unexpected value.
The task runs with the proper user.

Is there currently a reliable way to get the actual user that runs a task in a variable?

Kind regards,

Ramon de la Fuente
@F_U_E_N_T_E