Could not fetch updated apt files

When I try to do an ansible-playbook server.yml -e env=production -K on an existing server I receive this error:

TASK [common : Update Apt] *****************************************************
fatal: [my.server.ip.address]: FAILED! => {"changed": false, "failed": true, "msg": "Could not fetch updated apt files"}

I’ve reprovisioned this same server numerous times before without error, any idea?

This is most likely a connectivity issue.

Have you tried running with the -vvv flag?

When I try with the -vvv flag the error message in the last part of TASK [common : Update Apt] reads:

fatal: [my.server.ip.address]: FAILED! => {"changed": false, "failed": true, "invocation": {"module_args": {"cache_valid_time": null, "deb": null, "default_release": null, "dpkg_options": "force-confdef,force-confold", "force": false, "install_recommends": null, "package": null, "purge": false, "state": "present", "update_cache": true, "upgrade": null}, "module_name": "apt"}, "msg": "Could not fetch updated apt files"}

What kind of connectivity issue do you suspect? Between my server and the Ubuntu packages servers?

I’ve run into this problem as well intermittently. It always fixes itself after a bit. It’s likely a connectivity issue either between your server and Ubuntu packages, or simply with Ubuntu packages.

I ssh’d into the server and ran apt-update manually, the php7 ppa seems to be the culprit:

W: Failed to fetch http://ppa.launchpad.net/ondrej/php-7.0/ubuntu/dists/trusty/main/binary-amd64/Packages  404  Not Found

W: Failed to fetch http://ppa.launchpad.net/ondrej/php-7.0/ubuntu/dists/trusty/main/binary-i386/Packages  404  Not Found
1 Like

Thanks for following up.

It is a connection issue, but it won’t fix itself. The PPA changed early last month (Feb 5th), so you will need to update it. There have also been a few changes to the PHP role (updated modules, fixes for xdebug) which are worth incorporating too.

You can check the history on GitHub: https://github.com/roots/trellis/commits/master/roles/php/tasks/main.yml

Do I have to manually change the PPA on the server (if so, could you give a pointer how that’s done?), or should that change automatically when reprovisioning after Trellis is updated? The thing is I’ve just updated Trellis, but still receive the PPA error message.

sudo ppa-purge ppa:ondrej/php-7.0 on the server, and then re-provisioning and deploying should suffice.

It’s destructive (removing packages) so remember to back everything up first.

5 Likes

Thanks Nick, seems to work now. Needed to install PPA purge first (apt-get install ppa-purge).

1 Like