有什么办法可以让角色的一部分像这样: 我需要运行五次nrpe.cfg中的命令(在配置文件中有5条命令 - 所以5×5的命令)?Ansible - 同时使用with_items和with_sequence
- name: grep the commands from nagios
shell: grep -R check_http_ /etc/nagios/nrpe.cfg | cut -d= -f2-
register: nagios_check
- name: check_before
shell: (printf $(echo '{{ item }}' | awk -F'country=' '{print $2}' | cut -d'&' -f1); printf ' ';{{ item }} | cut -d ' ' -f-2) >> {{ ansible_env.DATA_LOG }}/eden-{{ dateext.stdout }}
register: checkedenbefore
with_items: "{{ nagios_check.stdout_lines }}"
**with_sequence: count=5**
ignore_errors: True
您的答案中的主要问题是,它不是一个单一的角色。所以基本上没有“干净”的方式来重复一个有“with_items”的任务(x次)? – ady8531
不知道这是什么意思:它不是一个单一的角色 – udondan
在你的答案中你使用了2个角色:main.yml和check_before.yml不是一个 – ady8531