I have to do some benchmarks and loop over 10 commands 3 times (run all 10x3, not the firstx3 then the secondx3 - so run all 10x3). The 10 commands I extract from a file in
You can put the tasks you want to repeat in a separate yaml file:
---
# tasks-to-repeat.yml
- name: get the date for naming purpose
shell: date +%Y%m%d-%HH%MM%SS
register: dateext
- name: grep the commands from nagios
shell: grep -R check_http_EDEN_ /etc/nagios/nrpe.cfg | cut -d= -f2-
register: nagios_check
- name: check_eden_before
shell: (printf $(echo '{{ item }}' | awk -F'country=' '{print $2}' | cut -d'&' -f1); printf ' ';{{ item }} | cut -d ' ' -f-2) >> {{ ansible_env.DATA_LOG }}/eden-{{ ansible_hostname }}-{{ dateext.stdout }}
with_items: "{{ nagios_check.stdout_lines }}"
ignore_errors: True
- name: enter simple line
shell: echo "=================" >> {{ ansible_env.DATA_LOG }}/eden-{{ ansible_hostname }}-{{ dateext.stdout }}
and then include it in your playbook 3 times:
---
# Your playbook
... more code above
- include: task-to-repeat.yml
- include: task-to-repeat.yml
- include: task-to-repeat.yml