apt fails with root privileges

17 views
Skip to first unread message

hamzeh alsalhi

unread,
Jun 24, 2015, 3:37:52 PM6/24/15
to ansible...@googlegroups.com
When I try to run the command:

  - name: update apt-get
    apt: update_cache=yes

I get:

msg: Failed to lock apt for exclusive operation

Even though my users are configured 

---
- hosts: ec2
  remote_user: ubuntu
  sudo_user: ubuntu
  sudo: yes
  gather_facts: true
  tasks:

and I can ssh into the machine on user ubuntu and execute apt-get update just fine.

ubuntu@ip-172-31-29-77:~$ sudo apt-get update
....
Fetched 1,829 kB in 1s (917 kB/s)
Reading package lists... Done

how I can I use Ansible to execute this command as the user ubuntu successfully?

Brian Coca

unread,
Jun 26, 2015, 9:50:33 AM6/26/15
to ansible...@googlegroups.com
sudo_user is the user you become, not the user executing sudo, remove
it and it will default to root or set sudo_user: root

I know this is confusing if you know about the sudo environment
variables that is why we deprecated this syntax in favor of
become_user: in newer versions.


--
Brian Coca
Reply all
Reply to author
Forward
0 new messages