一遍遍多个Ansible任务 [英] One loop over multiple Ansible tasks
问题描述
我创建了一个Ansible剧本,该剧本创建了一个云实例,然后在该实例上安装了一些程序.我想多次运行此剧本(不使用bash脚本).是否可以使用循环将这两个任务一起循环(即,一个循环执行两个任务?).到目前为止,我所能找到的只是每个任务的一个循环
I've created an Ansible playbook that creates a cloud instance and then installs some programs on the instance. I want to run this playbook multiple times (without using a bash script). Is it possible to use a loop to loop over those two tasks together (I.E. One loop for two tasks?). All I've been able to find so far is one loop for each individual task
推荐答案
否当前无法实现. with_items
过去曾与Ansible的早期版本中的include
语句一起使用,但不幸地被删除了.
No that's currently not possible. with_items
used to work with the include
statement in previous versions of Ansible but was unfortunately dropped.
Though it will be brought back in Ansible 2.0, see slide 14/15 of What's New in v2 - AnsibleFest London 2015
您可以尝试使用github上的 v2分支,该功能应为在那里可用.
You could try to work with the v2 branch from github, the feature should be available in there.
1.9.1所能做的就是将任务移到一个角色中,并在剧本中多次引用该角色.
What you can do with 1.9.1 is to move your tasks into a role and reference this role multiple times in your playbook.
这篇关于一遍遍多个Ansible任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!