标签:for 分发 情况 工作 问题 mod tst file 需求
最近换了工作,刚入职领导给我一个听着特复杂的需求,要实现自动发布:{% if grains[‘fqdn_ip4‘][0] == ‘10.1.10.86‘ %} #先判断ip,然后set2个不同的变量
{% set motd = [‘/opt/eth-btc-match/eth2btc‘, ‘/opt/zsc-eth-match/zsc2eth‘] %}
{% for motdfile in motd %} #通过for循环,取出
{{ motdfile }}:
file.managed:
- source: salt://match/files/CMatchModule
- backup: minion
{% endfor %}
{% elif grains[‘fqdn_ip4‘][0] == ‘10.1.10.88‘ %}
{% set motd = [‘/opt/zec-btc-match/zec2btc‘, ‘/opt/zec-eth-match/zec2eth‘] %}
{% for motdfile in motd %}
{{ motdfile }}:
file.managed:
- source: salt://match/files/CMatchModule
- backup: minion
{% endfor %}
{% elif grains[‘fqdn_ip4‘][0] == ‘10.1.10.89‘ %}
{% set motd = [‘/opt/ven-btc-match/ven2btc‘, ‘/opt/ven-eth-match/ven2eth‘] %}
{% for motdfile in motd %}
{{ motdfile }}:
file.managed:
- source: salt://match/files/CMatchModule
- backup: minion
此处省略很多
{% elif grains[‘fqdn_ip4‘][0] == ‘10.1.10.217‘ %}
{% set motd = [‘/opt/luc-eth-match/luc2eth‘, ‘/opt/sead-usdt-match/sead2usdt‘] %}
{% for motdfile in motd %}
{{ motdfile }}:
file.managed:
- source: salt://match/files/CMatchModule
- backup: minion
{% endfor %}
{% elif grains[‘fqdn_ip4‘][0] == ‘10.1.10.218‘ %}
{% set motd = [‘/opt/bnb-usdt-match/bnb2usdt‘, ‘/opt/ht-usdt-match/ht2usdt‘] %}
{% for motdfile in motd %}
{{ motdfile }}:
file.managed:
- source: salt://match/files/CMatchModule
- backup: minion
{% endfor %}
{% endif %}
标签:for 分发 情况 工作 问题 mod tst file 需求
原文地址:http://blog.51cto.com/9682938/2134938