LemmyNet / lemmy-ansible

A docker deploy for ansible
GNU Affero General Public License v3.0
248 stars 94 forks source link

Issues upgrading from 0.18.3 to 0.18.5 - Failed to lock apt for exclusive operation #216

Closed RyantHults closed 5 months ago

RyantHults commented 6 months ago

Trying to update my Lemmy install from 0.18.3. Started off by trying to upgrade from 0.18.3 to 0.18.5. I followed the steps from https://github.com/LemmyNet/lemmy-ansible#upgrading for this process and am now trying to run my regular deployment command ansible-playbook -i inventory/hosts lemmy.yml --become-user lemmy-admin --ask-become-pass

It gets to the install aptitude task and throws the following error fatal: [lemmy-admin@domain.tld]: FAILED! => {"changed": false, "msg": "Failed to lock apt for exclusive operation: Failed to lock directory /var/lib/apt/lists/: E:Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)"}

searching around, this appears to be a common ansible issue, but all of the common solutions don't seem to work. what I've tried so far:

All still result in the same error. My lemmy-admin account is able to run sudo. Any thoughts on how to fix this?

sanatsathaye commented 6 months ago

Running chmod to change permissions of system folders isn't recommended at all... You need to use become along with become-user.

ansible-playbook -i inventory/hosts lemmy.yml --become --become-user lemmy-admin --ask-become-pass

RyantHults commented 6 months ago

I understand that it's not likely the best option, (especially considering it didn't work), but that was what was suggested elsewhere online, and it was easy enough to revert when it didn't work.

running with the --become option causes the Check for legacy passwords/postgres file step to fail with Failed to set permissions on the temporary files Ansible needs to create when becoming an unprivileged user. reading the linked ansible page about this says to ensure setfacl is installed. It was not, but installing it did not resolve the issue.

Any idea why I would have to use --become now when I didn't have to before?

sanatsathaye commented 6 months ago

Does --become-user even work without --become? Both are required from what I recall.

Why not just set up passwordless ssh from your source system directly to lemmy-admin? Will be easier to manage.

ticoombs commented 5 months ago

Could not open lock file /var/lib/apt/lists/lock

This is normally because apt is already running on the system. But as you have shown you can still have problems when you are running as a non-root user. We have since removed the install aptitude item and as such this should no longer be an issue.

If you believe the issue still is an issue, please let us know.