linuxansibleorchestrationansible-ad-hoc

Ansible adhoc command with sudo


I'm tried to execute this command:

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

But the error is:

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

How to correct set directives of ansible adhoc to execute under root using sudo su -?


Solution

  • Forgot to use --become switch:

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