Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

842
Vistas
Ansible task timeout max length

I execute a shell: docker ps ... task in some of my playbooks. This normally works but sometimes the docker daemon hangs and docker ps does not return for ~2 hours.

How can I configure Ansible to timeout in a reasonable amount of time if docker ps does not return?

over 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

A task timeout is added in 2.10 release, which is useful in such scenario.

https://github.com/ansible/ansible/issues/33180

https://github.com/ansible/ansible/pull/69284

For example, below playbook fails in 2.10 version:

---
- hosts: localhost
  connection: local
  gather_facts: false
  tasks:
  - shell: |
      while true; do
        sleep 1
      done
    timeout: 5
...

with an error message like:

TASK [shell] **************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "The shell action failed to execute in the expected time frame (5) and was terminated"}
over 4 years ago · Santiago Trujillo Denunciar

0

There is no timeout-for-a-task-functionality implemented in Ansible.

You can try a workaround using asynchronous call, but for this case (clearly a kind of a bug) relying on the system might be easier and more appropriate.

See the GNU timeout command (if you run Docker, chances are the command is present on your OS):

shell: timeout 5m docker ps ...
over 4 years ago · Santiago Trujillo Denunciar

0

Weighing in on this in case someone comes across it, there was a timeout option added in a later version which allows you to specify the following variables in your inventory file on WinRM instances:

ansible_winrm_operation_timeout_sec: 120
ansible_winrm_read_timeout_sec: 150

My use case was a docker swarm init which is pretty messy on Windows but performs fine on Linux. It didn't resolve my issue but it may resolve yours depending on your transport.

I did also note https://github.com/ansible/ansible/pull/69284/files but this isn't explained anywhere that I could find.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda