# Execute commands remotely on a ubuntu

**URL:** <https://forum.ansible.com/t/execute-commands-remotely-on-a-ubuntu/20840>\
**Category:** Ansible Project\
**Tags:** fedora, ubuntu\
**Created:** [March 11, 2016, 1:25pm UTC](https://forum.ansible.com/t/execute-commands-remotely-on-a-ubuntu/20840 "2016-03-11T13:25:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vamberto\_Junior](https://avatars.discourse-cdn.com/v4/letter/v/dfb087/32.png) [@Vamberto\_Junior](https://forum.ansible.com/u/Vamberto_Junior)\
**Post date:** [March 11, 2016, 1:25pm UTC](https://forum.ansible.com/t/execute-commands-remotely-on-a-ubuntu/20840/1 "2016-03-11T13:25:26Z")

</div>

Hi everyone,

I am new user on ansible and I have a little difficulty to execute commands remotely on a Ubuntu Server. (Ubuntu don’t accept ssh with user root and the user vamberto can use sudo su - )  
My machine is a Fedora Linux and I execute this command: ansible -vvv wolverine -m apt -a “update\_cache=yes” --user=vamberto -k --become-method=su --become-user=root --ask-become-pass

And the server asks  
SSH password:  
SU password[defaults to SSH password]:

After I putt the ssh and su password I receive this error:

olverine | FAILED \>\> {  
“failed”: true,  
“msg”: “Failed to lock apt for exclusive operation”  
}

Someone can help me ?

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 11, 2016, 4:05pm UTC](https://forum.ansible.com/t/execute-commands-remotely-on-a-ubuntu/20840/2 "2016-03-11T16:05:16Z")

</div>

you can use sudo OR su but not chain them.

---

<div class="post-metadata">

**Author:** ![jorginator74](https://avatars.discourse-cdn.com/v4/letter/j/f19dbf/32.png) [@jorginator74](https://forum.ansible.com/u/jorginator74)\
**Post date:** [March 11, 2016, 5:59pm UTC](https://forum.ansible.com/t/execute-commands-remotely-on-a-ubuntu/20840/3 "2016-03-11T17:59:21Z")

</div>

APT takes out a lock to ensure that only one instance of a package  
manager is running. E.g. this can happen if you have synaptic open...

It is not an "ansible error" as such - just how the debian/ubuntu  
package manager work...

Hope this helps
