saltstack - for-loops

【基本介绍】
有时候我们又必要循环我们的配置达到执行多长的目的。

【简单实例】
遍历查看用户是否存在
{% 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

猜你喜欢

转载自runpanda.iteye.com/blog/2152776