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 Dec 18 '20 at 2:48
  • Same error {"changed": false, "cmd": "wich systemctl", "msg": "[Errno 2] No such file or directory", "rc": 2} Dec 18 '20 at 13:21

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, privacy policy and cookie policy

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