Getting rid of redundant Ansible roles I currently have a bunch of roles, like:


apache2
gcc
gedit
...etc.


For each of those, I have a task file that looks like this:

---
- name: "Install {{ role_name }}"
  become: true
  package:
    name: "{{ role_name }}"
    state: present


Is there a way to abstract this to a higher level and have a single "Install package" role, and then somehow specify a bunch of specific packages to install per host in a variable or something?
Is this what you're looking for?

- hosts: all
  vars:
    bunch_of_specific_packages:
      - apache2
      - gcc
      - gedit
  tasks:
    - package:
        name: "{{ item }}"
      loop: "{{ bunch_of_specific_packages }}"