【发布时间】:2015-09-17 15:53:54
【问题描述】:
有没有办法让角色成为这样的一部分: 我需要运行 nrpe.cfg 中的命令五次(配置文件中有 5 个命令 - 所以 5 x 5 个命令)?
- 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
【问题讨论】:
-
因为 ansible 2.1 版循环控制已经到位。使用此功能,您可以重命名您迭代的项目。因此内部和外部项目是可访问的。请参阅docs.ansible.com/ansible/latest/user_guide/… 了解此高频
标签: loops sequence roles ansible