I've got an Ansible role with several tasks that I run for several virtual hosts. My playbook works, and it looks like this:
---
- name: Create vhost configuration
# action
with_items: vhosts
- name: Ensure vhost is enabled
# action
notify: restart apache2
with_items: vhosts
# (Many more actions)
Is there a way to avoid having to write with_items
for every action? Can I iterate over the vhost items for the whole playbook rather than running each command for all vhosts sequentially? (as I am with the above code)
with_items
. However, a real example instead of "# action" would have made your question clearer and it might make others think of alternative ways to do what you are trying.include
andwith_dict
. But unfortunatly thats deprecated. Now I'm searching for a solution, too.