I was trying to execute a package installation task in a recently launched amazon EC2 instance via ansible. I have come across the following error
Failed to lock apt for exclusive operation
This bothered me a little because I have set the
connection: ssh before running the ansible-playbook yet the tasks ran into this error. As I wondered and looked for solutions I have come across the following solution that worked in my case. I have elevated the user privilege to
sudo by adding the following line to my main playbook.