]> git.phdru.name Git - ansible.git/blobdiff - playbooks/debian/roles/apache/tasks/main.yml
Feat(apache): Install and configure Apache; add a virtual host
[ansible.git] / playbooks / debian / roles / apache / tasks / main.yml
diff --git a/playbooks/debian/roles/apache/tasks/main.yml b/playbooks/debian/roles/apache/tasks/main.yml
new file mode 100644 (file)
index 0000000..1c6bd2f
--- /dev/null
@@ -0,0 +1,44 @@
+- 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