using Ansible command line:ansible-playbook --connection=local 127.0.0.1 playbook.ymlusing inventory:127.0.0.1 ansible_connection=localusing Ansible configuration file:[defaults] transport = localusing playbook header:- hosts: 127.0.0.1 connection:…
Turns out there’s another command simply called wsl
that lets you run arbitrary commands as arbitrary users:
>wsl -u root -d Ubuntu-18.04 -- echo "I am g$USER"
I am groot
N.B. you need to use separate args (instead of a string) for this one.
-d
is optional. You can change the default distro like
wslconfig.exe /l
wslconfig.exe /s Ubuntu-18.04
wslconfig.exe /l
wslconfig /l
appears to be equivalent to wsl --list