Ansible 1.6 include with_items deprecated

ansible, deprecated

Solution

There's no drop-in replacement, unfortunately. Some things you can do:

Pass the list to your included file and iterate there. In your playbook:

vars:
    sites:
       - site1
       - site2
tasks:
    - include: bootstrap_site.yml sites={{sites}}

And in bootstrap_site.yml:

- some_Task: ...
  with_items: sites

- another_task: ...
  with_items: sites

...

Rewrite bootstrap_site as a module (in python, bash, whatever), put it in a `library` dir next to your playbook. Then you could do:

- bootstrap_site: site={{item}}
  with_items: sites

Update: Ansible V2 is out and brings back the include + with_items combo loop!

Problem

So looks like this feature has been deprecated, i really don't understand why, Ansible CTO's says that we should use instead with_nested but honestly i have no idea how to do it, Here's my 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}} ``` And the error message when trying to execute this in Ansible 1.6.6: ERROR: [DEPRECATED]: include + with_items is a removed deprecated feature. Please update your playbooks. How can i convert this playbook to something that works with this ansible version?

Original source