Error running playbook in awx

[WARNING]: Updating cache and auto-installing missing dependency: python3-apt
fatal: [localhost]: FAILED! => {
“changed”: false,
“cmd”: “apt-get update”,
“invocation”: {
“module_args”: {
“allow_unauthenticated”: false,
“autoclean”: false,
“autoremove”: false,
“cache_valid_time”: 3600,
“deb”: nul…
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

I expected it to return ok but here are the error results, im using ubuntu server vm and this is my playbook

  • hosts: all
    become: true

    tasks:

    • name: Update apt cache
      apt:
      update_cache: yes
      cache_valid_time: 3600
      become: true
      environment:
      PATH: “{{ ansible_env.PATH }}:/usr/bin”

ps: new to ansible awx

Nobody will be able to help you since there isn’t any detail in your output. Try re-running your playbook and include the entire output. You’d also benefit from running your playbook in verbose mode to get more info. Also, please use the triple backticks (```) so that your code and output will be formatted better, ie:

[WARNING]: Updating cache and auto-installing missing dependency: python3-apt
fatal: [localhost]: FAILED! => {
  “changed”: false,
  “cmd”: “apt-get update”,
  “invocation”: {
  “module_args”: {
  “allow_unauthenticated”: false,
  “autoclean”: false,
  “autoremove”: false,
  “cache_valid_time”: 3600,
  “deb”: nul…
PLAY RECAP *********************************************************************
localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

done I use verbose level 3. I don’t know what’s the error it’s not on playbook I think it’s the environment problem not sure

cant edit my first post, heres another output of error

  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/var/lib/awx/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file
host_list declined parsing /tmp/bwrap_92_zis6_v8c/awx_92_tfik389d/tmpfiqqei07 as it did not pass its verify_file() method
Parsed /tmp/bwrap_92_zis6_v8c/awx_92_tfik389d/tmpfiqqei07 inventory source with script plugin
Skipping callback 'actionable', as we already have a stdout callback.
Skipping callback 'awx_display', as we already have a stdout callback.
Skipping callback 'counter_enabled', as we already have a stdout callback.
Skipping callback 'debug', as we already have a stdout callback.
Skipping callback 'dense', as we already have a stdout callback.
Skipping callback 'dense', as we already have a stdout callback.
Skipping callback 'full_skip', as we already have a stdout callback.
Skipping callback 'json', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'null', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.
Skipping callback 'selective', as we already have a stdout callback.
Skipping callback 'skippy', as we already have a stdout callback.
Skipping callback 'stderr', as we already have a stdout callback.
Skipping callback 'unixy', as we already have a stdout callback.
Skipping callback 'yaml', as we already have a stdout callback.

PLAYBOOK: playbookOpenLDAP installation.yml ************************************
1 plays in playbookOpenLDAP installation.yml

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
task path: /tmp/bwrap_92_zis6_v8c/awx_92_tfik389d/project/playbookOpenLDAP installation.yml:1
<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 `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1738896962.582673-254-267217861866111 `" && echo ansible-tmp-1738896962.582673-254-267217861866111="` echo /root/.ansible/tmp/ansible-tmp-1738896962.582673-254-267217861866111 `" ) && sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/system/setup.py
<localhost> PUT /var/lib/awx/.ansible/tmp/ansible-local-247zu7alai6/tmp0rbrcesz TO /root/.ansible/tmp/ansible-tmp-1738896962.582673-254-267217861866111/AnsiballZ_setup.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1738896962.582673-254-267217861866111/ /root/.ansible/tmp/ansible-tmp-1738896962.582673-254-267217861866111/AnsiballZ_setup.py && sleep 0'
<localhost> EXEC /bin/sh -c '/usr/bin/python3.6 /root/.ansible/tmp/ansible-tmp-1738896962.582673-254-267217861866111/AnsiballZ_setup.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1738896962.582673-254-267217861866111/ > /dev/null 2>&1 && sleep 0'
ok: [localhost]
META: ran handlers

TASK [Update apt cache] ********************************************************
task path: /tmp/bwrap_92_zis6_v8c/awx_92_tfik389d/project/playbookOpenLDAP installation.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 `"&& mkdir "` echo /root/.ansible/tmp/ansible-tmp-1738896964.2727194-304-240409917293190 `" && echo ansible-tmp-1738896964.2727194-304-240409917293190="` echo /root/.ansible/tmp/ansible-tmp-1738896964.2727194-304-240409917293190 `" ) && sleep 0'
Using module file /usr/lib/python3.6/site-packages/ansible/modules/packaging/os/apt.py
<localhost> PUT /var/lib/awx/.ansible/tmp/ansible-local-247zu7alai6/tmpxrao8asu TO /root/.ansible/tmp/ansible-tmp-1738896964.2727194-304-240409917293190/AnsiballZ_apt.py
<localhost> EXEC /bin/sh -c 'chmod u+x /root/.ansible/tmp/ansible-tmp-1738896964.2727194-304-240409917293190/ /root/.ansible/tmp/ansible-tmp-1738896964.2727194-304-240409917293190/AnsiballZ_apt.py && sleep 0'
<localhost> EXEC /bin/sh -c 'PATH=/var/lib/awx/venv/ansible/bin:/usr/pgsql-10/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin /usr/bin/python3.6 /root/.ansible/tmp/ansible-tmp-1738896964.2727194-304-240409917293190/AnsiballZ_apt.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /root/.ansible/tmp/ansible-tmp-1738896964.2727194-304-240409917293190/ > /dev/null 2>&1 && sleep 0'
The full traceback is:
  File "/tmp/ansible_apt_payload_cb4k721y/ansible_apt_payload.zip/ansible/module_utils/basic.py", line 2687, in run_command
    cmd = subprocess.Popen(args, **kwargs)
  File "/usr/lib64/python3.6/subprocess.py", line 729, in __init__
    restore_signals, start_new_session)
  File "/usr/lib64/python3.6/subprocess.py", line 1364, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
[WARNING]: Updating cache and auto-installing missing dependency: python3-apt
fatal: [localhost]: FAILED! => {
    "changed": false,
    "cmd": "apt-get update",
    "invocation": {
        "module_args": {
            "allow_unauthenticated": false,
            "autoclean": false,
            "autoremove": false,
            "cache_valid_time": 3600,
            "deb": null,
            "default_release": null,
            "dpkg_options": "force-confdef,force-confold",
            "force": false,
            "force_apt_get": false,
            "install_recommends": null,
            "only_upgrade": false,
            "package": null,
            "policy_rc_d": null,
            "purge": false,
            "state": "present",
            "update_cache": true,
            "upgrade": null
        }
    },
    "msg": "[Errno 2] No such file or directory: b'apt-get': b'apt-get'",
    "rc": 2
}

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

Hm,
Could you also share your playbook(s)?

Are you connecting to the host with root user? You should use a user with sudo permissions. If you are running apt update manually, does it work then?

1 Like

Are you using “apt” on a system that supports it, such as Ubuntu? You said you were a newbie to Ansible, which is fine, not a problem, but not every Linux OS uses apt for package updates. What is the target OS of the system you’re running this playbook against?

1 Like

hello I replace command module instead of apt module in my playbook, is that alright? Here’s my playbook sample:

``- name: Update apt cache
command: apt-get update
when: ansible_facts[‘distribution’] in [‘Ubuntu’]
tags:
- update_cache `

Yes, I’m currently using ubuntu for testing

Are you really sure you’re running Ubuntu? Python version shows Red Hat.

python version = 3.6.8 (default, Aug 24 2020, 17:57:11) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]