I’m having trouble running ansible plays as root. I have a user (user_x) on an Ubuntu server (12.04) who has sudo rights and I can run sudo commands on the server. I am able to ping the server and gather facts as user_x. However, when I run a play that requires sudo, in this case
Are you specifying “sudo: true” in the task or in the play? You can do that, or you can pass “–sudo” to the command line for a one-off setting for the entire playbook. But you do have to tell Ansible when/where to sudo.
I misunderstood and was trying to set sudo as a variable rather than a task/handler parameter.
Having watched your great Quick Start Video, I didn’t realize I’d have to use the -K option when calling the playbook, since Ubuntu’s default is to not enable a root user. In order to have the kind of effortless automation you demonstrate in the video I’d have to: a) run as root, b) use NOPASSWD in the sudoers file, or c) install the user_x’s ssh key in the root known_hosts file. Am I understanding this correctly?