Thats great info. At least it generally is able to run. 
The shebang is there to be able to call the playbook as ./apt.yml. 
For testing I removed the first two lines (comments) and on my fresh focal 
system it still fails:


PLAY [Install packages] 
******************************************************************************************************

TASK [Gathering Facts] 
*******************************************************************************************************
ok: [localhost]

TASK [install apt packages] 
**************************************************************************************************
fatal: [localhost]: FAILED! => {
    "changed": false
}

MSG:

<class 'apt_pkg.Cache'> returned a result with an error set

PLAY RECAP 
*******************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    
skipped=0    rescued=0    ignored=0   

root@station224:~# ansible-playbook -vvv apt.yml 
ansible-playbook 2.9.6
  config file = /root/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', 
'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.8.2 (default, Mar 13 2020, 10:14:16) [GCC 9.3.0]
Using /root/ansible.cfg as config file
host_list declined parsing /root/hosts as it did not pass its verify_file() 
method
script declined parsing /root/hosts as it did not pass its verify_file() method
auto declined parsing /root/hosts as it did not pass its verify_file() method
Parsed /root/hosts inventory source with ini plugin

PLAYBOOK: apt.yml 
************************************************************************************************************
1 plays in apt.yml

PLAY [Install packages]
******************************************************************************************************

TASK [Gathering Facts] 
*******************************************************************************************************
task path: /root/apt.yml:2
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
/root/.ansible/tmp/ansible-tmp-1587704463.5635076-240295718517288 `" && echo 
ansible-tmp-1587704463.5635076-240295718517288="` echo 
/root/.ansible/tmp/ansible-tmp-1587704463.5635076-240295718517288 `" ) && sleep 
0'
<localhost> Attempting python interpreter discovery
<localhost> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v 
'"'"'/usr/bin/python'"'"'; command -v '"'"'python3.7'"'"'; command -v 
'"'"'python3.6'"'"'; command -v '"'"'python3.5'"'"'; command -v 
'"'"'python2.7'"'"'; command -v '"'"'python2.6'"'"'; command -v 
'"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'/usr/bin/python3'"'"'; 
command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python2.7 && sleep 0'
Using module file /usr/lib/python3/dist-packages/ansible/modules/system/setup.py
<localhost> PUT /root/.ansible/tmp/ansible-local-16080wx54l1hi/tmpm8hhr014 TO 
/root/.ansible/tmp/ansible-tmp-1587704463.5635076-240295718517288/AnsiballZ_setup.py
<localhost> EXEC /bin/sh -c 'chmod u+x 
/root/.ansible/tmp/ansible-tmp-1587704463.5635076-240295718517288/ 
/root/.ansible/tmp/ansible-tmp-1587704463.5635076-240295718517288/AnsiballZ_setup.py
 && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 
/root/.ansible/tmp/ansible-tmp-1587704463.5635076-240295718517288/AnsiballZ_setup.py
 && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r 
/root/.ansible/tmp/ansible-tmp-1587704463.5635076-240295718517288/ > /dev/null 
2>&1 && sleep 0'
ok: [localhost]
META: ran handlers

TASK [install apt packages] 
**************************************************************************************************
task path: /root/apt.yml:5
<localhost> ESTABLISH LOCAL CONNECTION FOR USER: root
<localhost> EXEC /bin/sh -c 'echo ~root && sleep 0'
<localhost> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo 
/root/.ansible/tmp/ansible-tmp-1587704464.6301017-78793691417016 `" && echo 
ansible-tmp-1587704464.6301017-78793691417016="` echo 
/root/.ansible/tmp/ansible-tmp-1587704464.6301017-78793691417016 `" ) && sleep 
0'
Using module file 
/usr/lib/python3/dist-packages/ansible/modules/packaging/os/apt.py
<localhost> PUT /root/.ansible/tmp/ansible-local-16080wx54l1hi/tmprt46nqpu TO 
/root/.ansible/tmp/ansible-tmp-1587704464.6301017-78793691417016/AnsiballZ_apt.py
<localhost> EXEC /bin/sh -c 'chmod u+x 
/root/.ansible/tmp/ansible-tmp-1587704464.6301017-78793691417016/ 
/root/.ansible/tmp/ansible-tmp-1587704464.6301017-78793691417016/AnsiballZ_apt.py
 && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3 
/root/.ansible/tmp/ansible-tmp-1587704464.6301017-78793691417016/AnsiballZ_apt.py
 && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r 
/root/.ansible/tmp/ansible-tmp-1587704464.6301017-78793691417016/ > /dev/null 
2>&1 && sleep 0'
The full traceback is:
  File 
"/tmp/ansible_apt_payload_m2ufo6sl/ansible_apt_payload.zip/ansible/modules/packaging/os/apt.py",
 line 982, in get_cache
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 170, in __init__
    self.open(progress)
  File "/usr/lib/python3/dist-packages/apt/cache.py", line 232, in open
    self._cache = apt_pkg.Cache(progress)
fatal: [localhost]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 0,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "only_upgrade": false,
            "package": [
                "git"
            ],
            "pkg": [
                "git"
            ],
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": null,
            "upgrade": null
        }
    }
}

MSG:

<class 'apt_pkg.Cache'> returned a result with an error set

PLAY RECAP 
*******************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1    
skipped=0    rescued=0    ignored=0

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1874195

Title:
  ansible is not able to install packages via apt on 20.04

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ansible/+bug/1874195/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to