jms*_*rra 17 deprecated ansible ansible-playbook
所以看起来这个功能已经被弃用了,我真的不明白为什么,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]:include + with_items是已删除的已弃用功能.请更新你的剧本.
如何将此剧本转换为适用于此ansible版本的内容?
hka*_*iti 21
不幸的是,没有直接替代品.你可以做的一些事情:
将列表传递给您包含的文件并在那里迭代.在你的剧本中:
vars:
    sites:
       - site1
       - site2
tasks:
    - include: bootstrap_site.yml sites={{sites}}
在bootstrap_site.yml中:
- some_Task: ...
  with_items: sites
- another_task: ...
  with_items: sites
...
将bootstrap_site重写为一个模块(在python,bash,无论如何),将它放在library你的剧本旁边的一个目录中.然后你可以这样做:
- bootstrap_site: site={{item}}
  with_items: sites
更新: Ansible V2出来并带回include + with_items 组合循环!
| 归档时间: | 
 | 
| 查看次数: | 13658 次 | 
| 最近记录: |