Hello Stefan and Vladimir...

Yeah I think you are right, handling that in ansible would prevent me to 
put that retry-poison in shell, but it looks like there is no suitable 
solution in ansible, so I will put a shell wrapper in front of the scripts. 
Thank you very much for your thoughts...
Ivo

On Wednesday, April 29, 2020 at 10:52:47 AM UTC+2, 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 
>
>

-- 
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/bc913613-faa9-4ea1-933e-05dc12f54617%40googlegroups.com.

Reply via email to