I'm trying to run a shell command in an ansible task but I keep getting an error.

This is the task item and the shell command I want to run:

- name: Set File Watch Limit
    cmd: "echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p"

But this is the error that ansible gives me:

fatal: [...]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (command) module: cmd Supported parameters include: _raw_params, _uses_shell, argv, chdir, creates, executable, removes, stdin, stdin_add_newline, strip_empty_ends, warn"}

The reason I want to run the command is because it will address a problem that reactjs/nodejs developers are facing when they use npm run watch as explained in this related question: https://stackoverflow.com/questions/55763428/react-native-error-enospc-system-limit-for-number-of-file-watchers-reached

How do I get ansible to run the command? THe command works perfectly fine if I login to the server and manually execute it.

  • 1
    Are you sure the error belongs to this task? Oct 8, 2021 at 23:09
  • Yup, i deleted all other tasks from my playbook, this is the only action to perform Oct 8, 2021 at 23:33

1 Answer 1


Got it to work with this

- name: Set File Watch Limit
  shell: "echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p"

  • That is much cleaner looking ansible also.
    – chicks
    Oct 9, 2021 at 2:00

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.