running apt: update_cache=yes is failing the entire play

invalid output was: SUDO-SUCCESS-siogahtpvfcksvvxfxqslqrszpkxisfp
bzip2: (stdin) is not a bzip2 file.
bzip2: (stdin) is not a bzip2 file.
bzip2: (stdin) is not a bzip2 file.
bzip2: (stdin) is not a bzip2 file.
Traceback (most recent call last):
File “/home/vagrant/.ansible/tmp/ansible-tmp-1405754512.83-262599342047331/apt”, line 1762, in
main()
File “/home/vagrant/.ansible/tmp/ansible-tmp-1405754512.83-262599342047331/apt”, line 492, in main
cache.update()
File “/usr/lib/python2.7/dist-packages/apt/deprecation.py”, line 98, in deprecated_function
return func(*args, **kwds)
File “/usr/lib/python2.7/dist-packages/apt/cache.py”, line 418, in update
raise FetchFailedException(e)
apt.cache.FetchFailedException: W:Failed to fetch bzip2:/var/lib/apt/lists/partial/us.archive.ubuntu.com_ubuntu_dists_precise_main_binary-amd64_Packages Hash Sum mismatch
, W:Failed to fetch bzip2:/var/lib/apt/lists/partial/us.archive.ubuntu.com_ubuntu_dists_precise_restricted_binary-i386_Packages Hash Sum mismatch
, E:Some index files failed to download. They have been ignored, or old ones used instead.

So this is a traceback that looks like it needs to be caught to raise a proper error.

Please let us know what version of Ansible you are using, though in this case it seems like we need to catch an exception in the apt module.

Once you have pinned down the Ansible version, please file a ticket at github.com/ansible/ansible per CONTRIBUTING.md and include the line from your playbook that you used to trigger the task, as well as the output above.

Just wanted to clarify some behavior – that this does not fail the entire play in a way that is abnormal.

It takes the host out of rotation for the rest of the playbook - the host has failed.

If there are other hosts under configuration, those hosts will still be configured, unless they have this same problem.

If it actually failed to download, and the exception was caught, and it returned failed=True, the same thing happens.

Think of this as “the message out of this error condition is not good”, basically, but the error condition would still be there.

The question of why may deal with the upstream repo or your network or apt configuration, I’m not sure.