擅长:python、mysql、java
<p>我找到了另一个解决方案:</p>
<pre class="lang-yaml prettyprint-override"><code>- hosts: localhost
connection: local
gather_facts: False
vars:
gs_hostname: [gs-01, gs-02, gs-03, gs-04, gs-05, gs-06, gs-07]
wl_hostname: [wl-01, wl-02, wl-03]
tasks:
- debug:
msg: "{% set wl_list = wl_hostname %}
{% set row_class = cycler(* wl_list) %}
{% for gs in gs_hostname %}{{ gs }} - {{ row_class.next() }}{% endfor %}"
</code></pre>
<p>更多信息<a href="https://jinja.palletsprojects.com/en/2.11.x/templates/#cycler" rel="nofollow noreferrer">here</a></p>