From 05c9099fdfbd4ea5502364f4103d26cc9c6dbef8 Mon Sep 17 00:00:00 2001
From: Corbin Bartsch <me@cbarts.net>
Date: Mon, 11 Apr 2022 18:20:23 -0400
Subject: [PATCH] Moved site enabler task out of handler

---
 handlers/main.yaml      | 3 ---
 tasks/apache2_site.yaml | 4 ++++
 tasks/main.yaml         | 4 ++++
 3 files changed, 8 insertions(+), 3 deletions(-)
 create mode 100644 tasks/apache2_site.yaml

diff --git a/handlers/main.yaml b/handlers/main.yaml
index 0a28323..7ad8579 100644
--- a/handlers/main.yaml
+++ b/handlers/main.yaml
@@ -1,7 +1,4 @@
 ---
-- name: Enable Nextcloud site
-  ansible.builtin.command: a2ensite nextcloud.conf
-
 - name: Restart Apache
   ansible.builtin.systemd:
     name: httpd
diff --git a/tasks/apache2_site.yaml b/tasks/apache2_site.yaml
new file mode 100644
index 0000000..e6687a4
--- /dev/null
+++ b/tasks/apache2_site.yaml
@@ -0,0 +1,4 @@
+---
+- name: Enable Nextcloud site
+  ansible.builtin.command: a2ensite nextcloud.conf
+  when: not nextcloud_nginx and not nextcloud_ssl
diff --git a/tasks/main.yaml b/tasks/main.yaml
index 3a90815..218dfb1 100644
--- a/tasks/main.yaml
+++ b/tasks/main.yaml
@@ -10,6 +10,10 @@
   include_tasks: apache2_modules.yaml
   when: not nextcloud_nginx
 
+- name: Enable Apache2 site
+  include_tasks: apache2_site.yaml
+  when: not nextcloud_nginx
+
 - name: Create nginx config
   include_tasks: nginx_template.yaml
   when: nextcloud_nginx