--- - name: packages are installed (stretch) apt: name: '{{ item }}' state: present with_items: - apache2 - libapache2-mpm-itk - libapache2-mod-evasive - apachetop - libwww-perl tags: - apache - packages when: ansible_distribution_release == "stretch" - name: packages are installed (jessie) apt: name: '{{ item }}' state: present with_items: - apache2-mpm-itk - libapache2-mod-evasive - apachetop - libwww-perl tags: - apache - packages when: ansible_distribution_release == "jessie" - name: basic modules are enabled apache2_module: name: '{{ item }}' state: present with_items: - rewrite - expires - headers - cgi tags: - apache - name: Copy Apache defaults config file copy: src: evolinux-defaults.conf dest: "/etc/apache2/conf-available/z-evolinux-defaults.conf" owner: root group: root mode: "0640" force: yes tags: - apache - name: Copy Apache custom config file copy: src: evolinux-custom.conf dest: "/etc/apache2/conf-available/zzz-evolinux-custom.conf" owner: root group: root mode: "0640" force: no tags: - apache - name: Ensure Apache config files are enabled command: "a2enconf {{ item }}" register: command_result changed_when: "'Enabling' in command_result.stderr" with_items: - z-evolinux-defaults.conf - zzz-evolinux-custom.conf tags: - apache - include: auth.yml - name: default vhost is installed template: src: evolinux-default.conf.j2 dest: /etc/apache2/sites-available/000-evolinux-default.conf mode: "0640" # force: yes notify: reload apache tags: - apache - name: default vhost is enabled file: src: /etc/apache2/sites-available/000-evolinux-default.conf dest: /etc/apache2/sites-enabled/000-default.conf state: link force: yes notify: reload apache when: apache_evolinux_default_enabled tags: - apache - name: is umask already present? command: "grep -E '^umask ' /etc/apache2/envvars" failed_when: False changed_when: False register: envvar_grep_umask check_mode: no tags: - apache - name: Add a mark in envvars for umask blockinfile: dest: /etc/apache2/envvars marker: "## {mark} ANSIBLE MANAGED BLOCK" block: | ## Set umask for writing by Apache user. ## Set rights on files and directories written by Apache umask 007 when: envvar_grep_umask.rc != 0 tags: - apache - name: Stat /default index stat: path: /var/www/index.html register: _default_index check_mode: no tags: - apache when: apache_phpmyadmin_set - include: phpmyadmin.yml when: apache_phpmyadmin_set and _default_index.stat.exists - name: Check if log2mail is installed apt: name: log2mail state: present - name: Add log2mail config for Apache segfaults template: src: log2mail-apache.j2 dest: "/etc/log2mail/config/apache" owner: root group: root mode: "0644" force: no # - block: # - name: generate random string for serverstatus suffix # command: "apg -a 1 -M N -n 1" # changed_when: False # register: _random_serverstatus_suffix # # - name: overwrite apache_serverstatus_suffix # set_fact: # apache_serverstatus_suffix: "{{ _random_serverstatus_suffix.stdout }}" # when: apache_serverstatus_suffix == "" # # - name: replace server-status suffix in default site index # replace: # dest: /var/www/index.html # regexp: '__SERVERSTATUS_SUFFIX__' # replace: "{{ apache_serverstatus_suffix }}"