Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

843
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda