On 4/29/20 10:52 AM, Ivo Hechmann wrote:
> Hello team,
> 
> i want to call a shell script from ansible, this script may fail, so ansible 
> should retry the command, lets say 5 tries:
> 
> 
> - name: process something, fail if not 5 files in tmpdir
> shell: "/home/ivo/workspace/splunk-envs/scripts/retry/run.sh"
> ignore_errors: True
> register: status_var
> until: status_var is not failed
> delay: 1
> retries: 4
> 
> That works pretty fine. Now, how can I pass the retry number to the run.sh? 
> The script should log, and it would be nice
> if the script would know if there will be a retry on failure or not (last run 
> or so). 
> I saw in documentation that there is some loop_control and 
> ansible_loop_index, but i cannot combine these variables with
> the shell command in an until-loop. Is there a syntax problem or some better
> way the achieve my goal?
> 
> What I have tried: 
> 
> - name: process something, fail if not 5 files in tmpdir
> loop_control:
> extended: yes
> shell: "/home/ivo/workspace/splunk-envs/scripts/retry/run.sh {{ 
> lookup('vars', ansible_loop.index) }}"
> ignore_errors: True
> register: status_var
> until: status_var is not failed
> delay: 1
> retries: 4
> 
> Thank you very much for any hints on this...
> Ivo 

I don't understand why Ansible should handle the retries. Write a proper script 
or a wrapper around the existing one.

Regards
        Racke

> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to
> [email protected] 
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/f489599e-f1fc-4f32-b64e-7aa77293e6b2%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/f489599e-f1fc-4f32-b64e-7aa77293e6b2%40googlegroups.com?utm_medium=email&utm_source=footer>.


-- 
Ecommerce and Linux consulting + Perl and web application programming.
Debian and Sympa administration. Provisioning with Ansible.

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/113a13a0-e66c-4dbd-bf86-a9df165248d5%40linuxia.de.

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to