带有 sudo 的 Ansible adhoc 命令

Ansible adhoc command with sudo

我尝试执行此命令:

ansible somegroup -m raw -a "docker ps -a" --ask-pass -K --become-user root

但是错误是:

Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock:

如何使用 sudo su - 更正 ansible adhoc 的设置指令以在 root 下执行?

忘记使用--become开关:

ansible somegroup -m raw -a "docker ps -a" --ask-pass -K --become
ansible somegroup -b -m raw -a "docker ps -a"