a2enmod はモジュールがある
https://docs.ansible.com/ansible/latest/collections/community/general/apache2_module_module.html
a2enconf a2ensite
--- - name: Creating confs template: src: "{{ item.template }}" dest: "/etc/apache2/conf-available/{{ item.id }}.conf" owner: root group: root mode: "0644" when: item.template is defined with_items: "{{ apache2_confs }}" - name: Enabling confs command: > a2enconf {{ item.id }} args: creates: "/etc/apache2/conf-enabled/{{ item.id }}.conf" when: item.state is not defined or item.state != 'absent' with_items: "{{ apache2_confs }}" notify: test and reload apache2
https://github.com/weareinteractive/ansible-apache2/blob/master/tasks/manage_confs.yml