--- /dev/null
+- name: Check apache
+ command: test -L /etc/apache2/conf-enabled/001-phd.conf
+ failed_when: false
+ register: apache
+ changed_when: apache.rc != 0
+
+- debug:
+ msg: "apache has already been configured"
+ when: apache.rc == 0
+
+- name: Install apache
+ become: true
+ apt:
+ autoclean: yes
+ autoremove: yes
+ install_recommends: no
+ name: apache2
+ purge: yes
+ state: latest
+ update_cache: yes
+ when: apache.rc != 0
+
+- name: Enable SSL module
+ become: true
+ command: a2enmod ssl
+ notify: Reload apache
+ when: apache.rc != 0
+
+- name: Configure apache
+ become: true
+ template:
+ src: 001-phd.conf
+ dest: /etc/apache2/conf-available
+ owner: root
+ group: root
+ mode: '0640'
+ force: no
+ when: apache.rc != 0
+
+- name: Enable config
+ become: true
+ command: a2enconf 001-phd
+ notify: Reload apache
+ when: apache.rc != 0