Meiram Chuzhenbayev
Meiram Chuzhenbayev

Reputation: 906

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 -?

Upvotes: 2

Views: 6186

Answers (3)

Abhimanyu
Abhimanyu

Reputation: 55

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

-m = This is raw,

-a = To run ad-hoc command,

--ask-pass = ssh password,

-K --become = To become root or sudo,

You can read more on "How to use Ansible"

Upvotes: 0

Kandasamy Murugan
Kandasamy Murugan

Reputation: 125

ansible somegroup -b -m raw -a "docker ps -a" 

Upvotes: -1

Konstantin Suvorov
Konstantin Suvorov

Reputation: 68339

Forgot to use --become switch:

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

Upvotes: 7

Related Questions