所以看起来这个功能已经被弃用了,我真的不明白为什么,Ansible CTO说我们应该使用with_nested但老实说我不知道怎么做,
这是我的playboook:
- hosts: all
user: root
vars:
- sites:
- site: site1.com
repo: ssh://hg@bitbucket.org/orgname/reponame
nginx_ssl: true;
copy_init:
- path1/file1.txt
- path2/file2.php
- path2/file3.php
- site: site2.net
repo: ssh://hg@bitbucket.org/orgname/reposite2
- site: site4.com
repo: ssh://hg@bitbucket.org/orgname/reposite3
copy_init:
- path2/file2.php
tasks:
- name: Bootstrap Sites
include: bootstrap_site.yml site={{item}}
并尝试在Ansible 1.6.6中执行此错误消息:
错误:[DEPRECATED]:包含with_items是已删除的已弃用功能 . 请更新你的剧本 .
如何将此剧本转换为适用于此ansible版本的内容?
2 回答
不幸的是,没有直接替代品 . 你可以做的一些事情:
在bootstrap_site.yml中:
library
目录中 . 然后你可以这样做:Update: Ansible V2已经退出并带回包含with_items combo loop!
我找到了一个答案来规避blahblah弃用的消息......正如原帖中所说的那样 .
我添加了一个文件vars / filenames.yml:
接下来我在剧本的开头读了这些名字:
然后,我可以在以后使用它们:
等等....
问候,汤姆