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