sudo permissions with apt module

1,285 views
Skip to first unread message

Rishabh Goyal

unread,
Mar 15, 2016, 12:25:00 PM3/15/16
to Ansible Project
Hi,

I am trying to use apt module for installing multiple packages on my remote host. My user is not in sudoers list. However, I do have permissions to run following commands on remote host

sudo apt-get update
sudo apt-get install top

Now when I am trying to achieve same using ansible playbook, I am getting following error -

FAILED! => {"failed": true, "msg": "Missing sudo password"}

Following is my task definition

- name: install basic packages
  apt: name={{item}} update_cache=yes
  become: yes
  become_method: sudo
  with_items:
    - tree
    - nload
    - htop

I have tried removing become and become_method. Then I am getting standard dpkg lock error with -vvv flag - 
Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)\nE: Unable to lock the administration directory (/var/lib/dpkg/), are you root?\n

What could be potential issue here ?

Brian Coca

unread,
Mar 18, 2016, 11:31:51 PM3/18/16
to ansible...@googlegroups.com
ansible is not using those commands and will not work with restricted sudo in that way, it needs full sudo to accomplish these tasks. Most of the work of the apt module is using the apt-python API.


----------
Brian Coca

Johannes Kastl

unread,
Mar 19, 2016, 7:24:38 AM3/19/16
to ansible...@googlegroups.com
Am 19.03.16 schrieb Brian Coca:
> ansible is not using those commands and will not work with restricted sudo
> in that way, it needs full sudo to accomplish these tasks. Most of the work
> of the apt module is using the apt-python API.

So either change your permissions on the system or use the shell or
command modules instead of the apt module. I would go for the first one...

Regards,
Johannes


signature.asc
Reply all
Reply to author
Forward
0 new messages