Say I want to execute the following command on target hosts (deployed on GCP): ansible all -a "head -1 /etc/shadow". The command demands the root access. With the default Ansible configuration, I get the following error:

host1 | FAILED | rc=1 >>
head: cannot open '/etc/shadow' for reading: Permission deniednon-zero return code

Hence, I extended my ansible.cfg to include the following:

remote_user = gcp_user

Despite these changes, I can't run the command mentioned above. I still get the same error. I am, however, capable of executing the following command: ansible all -a "sudo cat /etc/shadow"

Thus, it seems that become_user=yes does not take any effect.

  • Try without sudo and --become as argument May 29 at 11:31


Your Answer

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