Thanks, Tim. 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? Thanks much! Steve On Friday, February 21, 2014 2:25:48 PM UTC-6, Timothy Gerla wrote: > > Hi Steve, > > 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. > > Hope this helps! > > -Tim > > > On Fri, Feb 21, 2014 at 1:32 PM, Steve Smith <[email protected]<javascript:> > > wrote: > >> 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 >> >> -name: ensure apache & php are installed >> apt: pkg={{ item }} state=present update_cache=yes >> cache_valid_time=86400 >> with_items: >> - apache2 >> - php5 >> >> >> The play fails with the error >> >> msg: 'apt-get install 'apache2' 'php5' ' failed: E: Could not open lock >> file /var/lib/dpkg/lock - open (13: Permission denied) >> >> E: Unable to lock the administration directory (/var/lib/dpkg/), are you >> root? >> >> >> The variables are the defaults and I'm calling the playbook like so >> >> ansible-playbook site.yml --limit staging >> >> >> Any help would be appreciated. >> >> >> >> >> >> -- >> 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] <javascript:>. >> To post to this group, send email to [email protected]<javascript:> >> . >> For more options, visit https://groups.google.com/groups/opt_out. >> > > > > -- > Tim Gerla > [email protected] <javascript:> > > -- 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/f3d48e37-2e0c-42f3-bd0d-4aa2b39e3fd9%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
