有什麼辦法可以讓角色的一部分像這樣: 我需要運行五次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