Here is my play book:
- name: Install MySQL with replication
hosts: mysql-master:mysql-slave
user: root
sudo: false
roles:
- common
- admin-users
- generic-directories
- { role: iptables, tags: [ 'mysql-iptables'] }
- mysql
I have ip tables tasks for different ports, I want to run the task depending on the group of servers. I have tagged the iptables task based on the group.
When i ran the play book instead of playing the tagged task, its run through all the tasks defined in iptables role.
Please let me know if am doing anything wrong here.
When you tag a role, you’re saying “all of the tasks in this role are x”, not “run only the tasks in that role already tagged x”. If you find yourself trying to run subsets of tasks in a role, you might want to consider breaking down your role into separate roles. A role isn’t really meant to be cut apart and have parts run separately–those would be separate roles.
-Tim