diff --git a/tasks/main.yml b/tasks/main.yml
index cd4ae8c08ad1854c299aa8faaa2e5a68d36d0be0..9b8fc2e09942b7e6108e516a97bf38b949f0c948 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -22,4 +22,4 @@
       tags:
         - always
 
-  when: (not excluded_roles or "apache" not in excluded_roles) and role_apache_completed is not defined
+  when: (not excluded_roles or "apache" not in excluded_roles) and role_apache_completed is not defined and groups and 'webserver' in groups and inventory_hostname in groups.webserver