You should use the group_by module.
It is highly misleading to think you can abstract away packaging by just selecting the package manager – names, config files, and other things are always different.
Think about how Apache has sites_enabled on Ubuntu, but not on RHEL, for instance. SELinux vs AppArmor. The list goes on.
The group_by idiom looks like this:
https://github.com/jsmartin/ansible-examples/blob/riak/riak/roles/bootstrap/common/tasks/main.yml
https://github.com/jsmartin/ansible-examples/blob/riak/riak/setup_riak.yml