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]> 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]. > To post to this group, send email to [email protected]. > For more options, visit https://groups.google.com/groups/opt_out. > -- Tim Gerla [email protected] -- 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]. For more options, visit https://groups.google.com/groups/opt_out.
