有时候我们又必要循环我们的配置达到执行多长的目的。
【简单实例】
遍历查看用户是否存在
{% for usr in 'cedwards','thatch','jphall','herlo','whiteinge','SEJeff' %} {{ usr }}: user: - present {% endfor %}
创建多个目录
[root@vpn sls_config]# cat test.sls {% for i in '1','2' %} test{{ i }}: file.directory: - name: /tmp/test{{ i }} {% endfor %}
【参考引用】
http://intothesaltmine.org/blog/html/2012/12/12/using_for_loops_in_salt_states.html