I need to run the same task 48 times under a block.
I did not find any information on how to do this. I need it to run under a block, because if it fails it will continue until it reaches 48 times. I would appreciate any information or suggestion on how to do this in the most correct way.
This is my code:
---
- name: Playbook for productaion - Exmpale
hosts: dev
become: true
become_user: root
tasks:
- name: Checking Performance test under block 48 times
block:
- name: Runing Performance Test
shell: nohup /root/test/run_pf_new.py &
args:
chdir: /root/test/
- name: Checking Performance Test
shell: /root/test/checking_pf_new.py > /root/test/out8 2>&1; cat /root/test/out8 | grep -iw 'ok' > /dev/null; if [ $? == 0 ]; then echo 'pass'; else echo 'fail'; fi
args:
chdir: /root/test/
async: 3600
poll: 1
register: pf
- debug: msg="Performance testing was successful"
when: pf.stdout == "pass"
- name: Reboot after removing the windows boot
reboot:
reboot_timeout: 600
when: pf.stdout == "pass"
- debug:
msg: "Performance test failed"
when: pf.stdout == "fail"
failed_when: pf.stdout == "fail"
rescue:
- debug:
msg: 'I caught an error under performance testing'