Playbook error-- "Failed to lock apt for exclusive operation"

Hi All,

I have configured ansible properly with 1 master and 1 node machine. Have configured the /etc/ansible/hosts file with

[webservers]
172.31.xx.xx ansible_ssh_user=ansibleuser ansible_ssh_pass=passwd.

and have written my playbook for installing apache webserver in node machine.

After execting my playbook, I am getting this error.

Note: When I execute the same playbook on hosts: localhost. its working fine.

Can somone help me to fix the issue.

Thanks.

Regards,
Dhamodharan.

This usually happens when there is another apt operation going on.
I sometimes have this if I spin up an instance from an image that is a
bit old and it has to download a lot of security updates.

Dick

Hi Dick,

Thanks for your revert, but I dont have any other apt operation running on my machine. Its a fresh machine and just configured for ansible operation and tried apache configuration in my ansible node.

I assume you have become=yes?

That also I have tried, even tried with sudo=yes, become_user=yes, remote_user=.

Nothing worked out…

That also I have tried, even tried with sudo=yes, become_user=yes, remote_user=.

Nothing worked out…

I would expect that when trying combinations of (partially outdated)
privilege escalation directives and random values.
However, it does indicate that privilege escalation _is_ the actual
problem though.

Please take a few minutes to read
https://docs.ansible.com/ansible/latest/user_guide/become.html, and
adjust your playbook and ansible invocation accordingly.

Dick