diff --git a/tasks/tunnel_keys.yml b/tasks/tunnel_keys.yml
index 91ff270b00eacad30d5031da5af648bf36138b4c..2e8a525450f7ed0fb862556a4c2a6b7ed5625c93 100644
--- a/tasks/tunnel_keys.yml
+++ b/tasks/tunnel_keys.yml
@@ -11,4 +11,4 @@
     key="{{ hostvars[item].pubkey.stdout }} {{ item }}"
     path='/home/{{ tunnel_user_name }}/.ssh/fresh_auth_keys_tunnel_{{ item }}'
   with_items: '{{ groups.all }}'
-  when: item != "localhost" and inventory_hostname != "localhost"
+  when: item != "localhost" and inventory_hostname != "localhost" and hostvars[item].pubkey is defined