]> git.phdru.name Git - ansible.git/blobdiff - playbooks/debian/roles/apache/tasks/main.yml
Fix: Set `directory_mode` for recursive copying
[ansible.git] / playbooks / debian / roles / apache / tasks / main.yml
index 1c6bd2f7848262a3ac5f25e126ad9caa08d39516..ac576c061c6a2cd2c23bbe08bebcfbd9288a9934 100644 (file)
@@ -1,44 +1,61 @@
 - name: Check apache
-  command: test -L /etc/apache2/conf-enabled/001-phd.conf
-  failed_when: false
-  register: apache
-  changed_when: apache.rc != 0
+  stat:
+    path: /etc/apache2/conf-enabled/001-phd.conf
+  register: phd_conf
+  changed_when: not phd_conf.stat.exists
 
 - debug:
     msg: "apache has already been configured"
-  when: apache.rc == 0
+  when: phd_conf.stat.exists
 
-- 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
+- block:
+    - name: Install apache
+      become: true
+      apt:
+        autoclean: yes
+        autoremove: yes
+        install_recommends: no
+        name: apache2
+        purge: yes
+        state: latest
+        update_cache: yes
 
-- name: Enable SSL module
-  become: true
-  command: a2enmod ssl
-  notify: Reload apache
-  when: apache.rc != 0
+    - name: Enable SSL module
+      become: true
+      command: a2enmod ssl
+      notify: Reload apache
+
+    - name: Configure apache
+      become: true
+      template:
+        src: 001-phd.conf
+        dest: /etc/apache2/conf-available
+        owner: root
+        group: root
+        mode: '0640'
+        force: no
+
+    - name: Setup default host
+      become: true
+      copy:
+        src: _default_
+        dest: /usr/local/apache2
+        owner: root
+        group: www-data
+        directory_mode: '0755'
+        mode: '0644'
 
-- name: Configure apache
+    - name: Enable config
+      become: true
+      command: a2enconf 001-phd
+      notify: Reload apache
+  when: not phd_conf.stat.exists
+
+- name: Configure logrotate
   become: true
-  template:
-    src: 001-phd.conf
-    dest: /etc/apache2/conf-available
+  copy:
+    src: apache2
+    dest: /etc/logrotate.d
     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