--- - name: Create index.html ansible.builtin.template: src: httpd/index.html.j2 dest: "{{ httpd_site_root }}/index.html" owner: www-data group: www-data mode: '0644' - name: Create Apache virtual host config ansible.builtin.template: src: httpd/vhost.conf.j2 dest: "/etc/apache2/sites-available/{{ httpd_site_name }}.conf" owner: www-data group: www-data mode: '0644' notify: Reload Apache - name: "Enable http site {{ httpd_site_name }}" ansible.builtin.command: "a2ensite {{ httpd_site_name }}" args: creates: "/etc/apache2/sites-enabled/{{ httpd_site_name }}.conf" notify: Reload Apache - name: Enable modules ansible.builtin.command: " a2enmod {{ item }}" args: creates: "/etc/apache2/mods-enabled/{{ item }}*" loop: "{{ httpd_default_enabled_modules + httpd_optional_enabled_modules }}" notify: Reload Apache