run command on ansible host with sudo privilege.

Hi guys, I am using:

  • hosts: 127.0.0.1
    connection: local

to execute command on the ansible host, I disabled privilege escalation because I would get an error message:

“module_stderr”: "sudo: effective uid is not 0, is /usr/bin/sudo on a file system with the ‘nosuid’ option set or an NFS file system without root privileges?

Im trying to execute the command: npm install --production. but some of the packages requires sudo permission to be installed

So now what?

:(.

Can you sudo normally on your machine?

You can also use su or other methods if sudo is not available on your machine, or execute the ansible itself as root.

become_user: root
become: true
become_method: sudo