Wednesday, April 6, 2022

[SOLVED] apt_repository module fails ansible

Issue

sometimes when I run my playbook it throws the next fail:

FAILED! => {"changed": false, "failed": true, "module_stderr": "", "module_stdout": "Traceback (most recent call last):\r\n  File \"/root/.ansible/tmp/ansible-tmp-1457967885.72-104659711487416/apt_repository\", 
line 3210, in <module>\r\n    main()\r\n  File \"/root/.ansible/tmp/ansible-tmp-1457967885.72-104659711487416/apt_repository\", line 469, in main\r\n`    `cache.update()\r\n  File \"/usr/lib/python2.7/dist-packages/apt/cache.py\", line 440, 
in update\r\n    raise FetchFailedException(e)\r\napt.cache.FetchFailedException: W:Imposible obtener` `http://security.ubuntu.com/ubuntu/dists/trusty-security/main/source/Sources`  `La suma hash difiere\r\n, 
W:Imposible obtener http://security.ubuntu.com/ubuntu/dists/trusty-security/main/binary-amd64/Packages  La suma hash difiere\r\n, W:Imposible obtener http://security.ubuntu.com/ubuntu/dists/trusty-security/main/binary-i386/Packages  La suma hash difiere\r\n, 
E:Algunos archivos de` `índice fallaron al descargar. Se han ignorado, o se han utilizado unos` `antiguos en su lugar\r\n", 
"msg": "MODULE FAILURE", "parsed": false}

the part of the playbook that 'sometimes' fails, is the next:

- name: ppa java8
  apt_repository: repo=ppa:webupd8team/java state=present update_cache=yes

Solution

run sudo apt-get -y clean && sudo apt-get -y autoclean before your task.



Answered By - ffghfgh
Answer Checked By - Willingham (WPSolving Volunteer)