Ansible:如何遍历数组中的角色? [英] Ansible: How to iterate over a role with an array?

查看:84
本文介绍了Ansible:如何遍历数组中的角色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在这样的循环中多次调用角色:

Is it possible to call a role multiple times in a loop like this:

vars:
  my_array:
    - foo
    - bar
    - baz 
roles:
  - role: foobar
    with_items: my_array

我们如何做到这一点?

推荐答案

Ansible 2.3开始支持.0 :

- name: myrole
  with_items:
    - "aone"
    - "atwo"
  include_role:
    name: myrole
  vars:
    thing: "{{ item }}"

这篇关于Ansible:如何遍历数组中的角色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆