first, the following line shows you should not need a password for doing sudo as 'foo' >foo ALL=(bar) NOPASSWD: ALL
In your command you are implying a double sudo while ansible only does one. ansible can connect as a remote user 'foo' and then use sudo to run a command as another user 'bar', to have that command also be sudo, you need to add that yourself, or allow 'foo' to sudo as root. for example, i believe this is what you want (with your inventory configured for remote user being 'foo' and sudo user being 'bar': ansible client-01 -m raw -a "sudo touch /etc/testfile" except it won't work, as ansible won't prompt you for the sudo password for 'bar' only for 'foo', which does not need one, but the reverse would work. foo ALL=(bar) ALL bar ALL=(ALL) NOPASSWD: ALL with this ansible can use the password prompt for 'foo' and then you can sudo to root from bar w/o a password. -- Brian Coca -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAJ5XC8mbEow_GxTx7unUTCn7nWbb5%2BetGVsKBFNHofX-V14%3DgA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
