I'm trying to run this command in a Amazon Linux AMI instance

  - name: Run docker
    shell: systemctl enable docker && systemctl start docker 

And receiving this error message

"stderr": "/bin/sh: systemctl: No such file or directory"

I already tried with command, ansible systemd module and /usr/bin/systemctl.

  • 1
    Try command: which systemctl and command: hostname Commented Dec 18, 2020 at 2:48
  • Same error {"changed": false, "cmd": "wich systemctl", "msg": "[Errno 2] No such file or directory", "rc": 2} Commented Dec 18, 2020 at 13:21

1 Answer 1


After struggling for a time I solved the problem by changing the image in the ci from Ubuntu to ansible-runner.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.