[root@master base]# vim test.sls
test_nginx_install:
pkg.installed:
{% if grains['os'] == 'CentOS Stream' %}
- name: httpd
{% elif grains['os'] == 'Ubuntu' %}
- name: apache1
{% endif %}
[root@master base]# salt '*' state.sls test
minion:
----------
ID: test_nginx_install
Function: pkg.installed
Name: httpd
Result: True
Comment: All specified packages are already installed
Started: 09:24:36.498688
Duration: 5372.631 ms
Changes:
Summary for minion1
------------
Succeeded: 1
Failed: 0
------------
Total states run: 1
Total run time: 5.631 s
此处省略N行……
循环语句
[root@master base]# vim test.sls
{% for user in ['yzy','yzy1'] %}
{
{ user }}:
user.present
{% endfor %}
[root@master base]# salt 'minion' state.sls test
minio