--- - name: Manage the apache packages on Ubuntu or Debian block: - name: Install the apache packages apt: pkg={{ apache_packages }} state={{ apache_pkg_state }} cache_valid_time=3600 tags: [ 'apache', 'apache_main_packages' ] - name: Install the apache modules packages apt: pkg={{ apache_modules_packages }} state={{ apache_pkg_state }} cache_valid_time=3600 when: not apache_from_ppa tags: [ 'apache', 'apache_additional_packages' ] - name: Install the apache additional packages, if any apt: pkg={{ apache_additional_packages_list }} state={{ apache_pkg_state }} cache_valid_time=3600 tags: [ 'apache', 'apache_additional_packages' ] - name: Instal the ports conf file template: src=ports.conf dest=/etc/apache2/ports.conf notify: apache2 reload tags: [ 'apache', 'apache_conf' ] - name: Remove the default virtualhost file file: dest=/etc/apache2/sites-enabled/{{ item }} state=absent with_items: - 000-default - 000-default.conf notify: apache2 reload when: ansible_distribution_file_variety == "Debian" tags: apache - name: Ensure that the apache service is enabled and started service: name=apache2 state=started enabled=yes when: apache_service_enabled ignore_errors: True tags: apache - name: Ensure that the apache service is disabled and stopped if we do not want it running service: name=apache2 state=stopped enabled=no when: not apache_service_enabled ignore_errors: True tags: apache