Ansible apt module hangs, process sleeping

ansibleansible-playbookdebian-buster

Ansible version: ansible 2.9.6
Remote servers: "Debian GNU/Linux 10 (buster)"
Ansible module: apt

I'm running a simple playbook on 2 debian 10 nodes.
I install Debian 10 with an ansible playbook on both nodes.

After that, I run the next role on a playbook:

- name: First, check if any package needs to be reconfigured
  command: >-
    dpkg --configure -a
  ignore_errors: true

- import_tasks: remove_apt_repository.yml
  tags:
    - system
    - apt
    - remove-repo
  when: remove_apt_repository_opt == 'yes'

- import_tasks: update_apt_cache.yml
  tags:
    - system
    - update-cache 
    - apt 

- import_tasks: add_apt_repository.yml
  tags:
    - system
    - apt
    - add-repo
  when: add_apt_repository_opt == 'yes'

- import_tasks: upgrade_all_packages.yml
  tags:
    - system
    - upgrade-packages 
    - apt
  when: upgrade_packages_repository_opt == 'yes'

- import_tasks: install_apt_packages.yml
  tags:
    - system
    - install-packages 
    - apt
  when: install_apt_packages_opt == 'yes' 

- import_tasks: install_pip_packages.yml
  tags:
    - system
    - install-packages
    - pip 
  when: install_pip_packages_opt == 'yes'

However, sometimes it gets stuck on the task Upgrade all packages. This is the task upgrade all packages:

- name: Upgrade all packages to the latest version
  apt:
    name: "*"
    state: latest

I check on the node, and there's a task on S state, and maybe it hangs for 20 minutes or it justs timeout. This pictures shows both nodes, on one the task is completed on the other one just hangs.

enter image description here

Here I show the playbook execution where it hangs:

enter image description here

Thanks for your help.

Best Answer

  • add some -vvv to your playbook run
  • find the command launched by ansible for this task
  • launch it manually whith some verbosity