tech:script_shell_commande_timeout
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Prochaine révision | Révision précédente | ||
| tech:script_shell_commande_timeout [2025/03/24 15:06] – créée - modification externe 127.0.0.1 | tech:script_shell_commande_timeout [2026/06/07 19:12] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 1: | Ligne 1: | ||
| + | < | ||
| + | {{tag> | ||
| + | |||
| + | # Script shell commande timeout | ||
| + | |||
| + | Voir aussi : | ||
| + | * waitmax https:// | ||
| + | |||
| + | ** A titre d' | ||
| + | |||
| + | Exemple de code Ansible | ||
| + | |||
| + | ~~~yaml | ||
| + | - name: command ldap_search | ||
| + | become: true | ||
| + | ansible.builtin.command: | ||
| + | / | ||
| + | changed_when: | ||
| + | check_mode: false | ||
| + | register: ldapsearch | ||
| + | environment: | ||
| + | LANG: C | ||
| + | failed_when: | ||
| + | - ldapsearch.rc != 0 # OK | ||
| + | - ldapsearch.rc != 124 # Timeout. SIGTERM | ||
| + | - ldapsearch.rc != 137 # Timeout. SIGKILL | ||
| + | |||
| + | - name: fail when timeout - SIGTERM | ||
| + | fail: | ||
| + | msg: " | ||
| + | when: ldapsearch.rc == 124 | ||
| + | |||
| + | - name: fail when timeout - SIGKILL | ||
| + | fail: | ||
| + | msg: " | ||
| + | when: ldapsearch.rc == 137 | ||
| + | |||
| + | - name: fail if ACME user | ||
| + | fail: | ||
| + | msg: | | ||
| + | Error_ElementAlreadyUsed. Nom de compte utilisateur déjà utilisé par ACME {{ CDO_ACCOUNT_USER }}. | ||
| + | when: | ||
| + | - ldapsearch.stdout_lines | select(' | ||
| + | - not allow_ldap_acme | ||
| + | ~~~ | ||
| + | |||
| + | Concernant Ansible voir aussi https:// | ||
| + | |||
| + | |||
| + | ## async pool timeout | ||
| + | |||
| + | `play1.yml` | ||
| + | ~~~yaml | ||
| + | # | ||
| + | |||
| + | --- | ||
| + | |||
| + | - name: test | ||
| + | hosts: localhost | ||
| + | gather_facts: | ||
| + | |||
| + | # TIMEOUT_MAX = async | ||
| + | # TIMEOUT_MAX = retries x delay # when poll == 0 | ||
| + | |||
| + | tasks: | ||
| + | - name: Command | ||
| + | shell: | | ||
| + | sleep 5 | ||
| + | date >> / | ||
| + | poll: 0 # When pool is a positive value, the playbook will still block on the task until it either completes, fails or timeout | ||
| + | async: 2 # if poll != 0 : fail when task is longer than async value | ||
| + | register: cmd_sleep | ||
| + | |||
| + | - name: DEBUG 10 | ||
| + | debug: | ||
| + | msg: " | ||
| + | |||
| + | - name: Async_status | ||
| + | async_status: | ||
| + | jid: "{{ cmd_sleep.ansible_job_id }}" | ||
| + | register: job_result | ||
| + | until: job_result.finished | ||
| + | retries: 3 # MAX TIMEOUT VAR | ||
| + | delay: 2 # MAX TIMEOUT VAR | ||
| + | |||
| + | - name: DEBUG 20 | ||
| + | debug: | ||
| + | msg: " | ||
| + | ~~~ | ||
| + | |||
