1. what Uditha said about 'testservers'. 2. By "use multiple plays", I meant to create one play that specifies hosts: testservers, another play that specifies hosts: dev-servers, and a third that specifies hosts: prod-servers. Then, have specific tasks for those servers.
Now, re-looking at your playbook, I realize that I had forgotten that you were using a role for this, so separating this into multiple plays would be more complicated because you want the role to act differently depending on the group. In general, this makes the role less portable because it requires that these groups be defined. So, if you wanted to go down this road, you could either split your role into multiple roles or split your tasks/main.yml into multiple files (this might be overkill for what you want to do, but I'm including it here for completeness): e.g. tasks/prod.yml: tasks to run on all prod-servers tasks/dev.yml: tasks to run on all dev-servers tasks/test.yml: task to run on all testservers tasks/main.yml: --- - name: Run on prod include: prod.yml when: run_prod|default(false) - name: Run on dev include: prod.yml when: run_dev|default(false) - name: Run on test include: test.yml when: run_test|default(false) and in your playbook: --- - name: Play for test servers hosts: testservers roles: - { role: app_install, run_test: true, tags: test } - name: Play for dev servers hosts: dev-servers roles: - { role: app_install, run_dev: true, tags: dev } - name: Play for prod servers hosts: prod-servers roles: - { role: app_install, run_prod: true, tags: prod } -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To post to this group, send email to ansible-project@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2785dd7b-41a6-4226-aa15-417565308f97%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.