【问题标题】:Loop and difference in chef template厨师模板中的循环和差异
【发布时间】:2020-04-29 12:28:28
【问题描述】:
{% for peer_ip in all_ips.split(',') | difference([source_ip]) %}
    {{ peer_ip }}
    {% endfor %}

其中 source ip 是运行该服务的服务器的 ip 地址,peer ip 是同一服务的辅助 ip。 all_ips 包含 2 个源 ip 和对等逗号分隔。

像这个ansible代码一样,我如何为厨师模板erb编写类似的东西,因为我对厨师很陌生。

如果有类似的问题,请指导我,在我有限的时间内找不到太多

非常感谢!

【问题讨论】:

  • 我是 ansible 的新手。 pipe (|)、difference 和 source_ip 是什么?您能用普通英语(不是ansible)说明您拥有哪些数据以及需要获取哪些数据吗?

标签: ansible chef-infra chef-template


【解决方案1】:

您可以将template resourceembedded-ruby (erb) 一起使用

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-02-20
    • 1970-01-01
    • 1970-01-01
    • 2014-05-29
    • 2015-03-20
    • 1970-01-01
    • 2015-05-31
    • 1970-01-01
    相关资源
    最近更新 更多