Missing SUPERVISOR_TOKEN when accessing Home Assistant using Ansible

I’m using Ansible to setup Home Assitant as I’m using it to control a fleet of remote installations.

When I log in with ssh normally (using the community ssh addon) SUPERVISOR_TOKEN is in the shell environment, but when I send commands using Ansible, SUPERVISOR_TOKEN isn’t there.

I’ve debugged the ssh command Ansible is using, and when I log in with the exact same comand, SUPERVISOR_TOKEN is present, so I’m pretty sure it’s not something to do with additional ssh arguments.

Is there any way I can work out what’s going on and have SUPERVISOR_TOKEN set for Ansible?

I did found a workaround from a thread on reddit, but it’d be helpful not to have to do this, as it requires an additional task to extract the TOKEN and then explicitly setting the variable for each subsequent task.