diff --git a/tasks/main.yml b/tasks/main.yml
index 49367d2a63c4fa0b28bd7767c4fb89f9e5fe61ef..e39ae5af58f634483ae605140654a5b80a7d127d 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -63,8 +63,7 @@
           IdentityFile /etc/ssh/deploy.key
 
 - name: Get hosts keys
-  with_items: '{{ deploy_key_repos }}'
-  command: ssh-keyscan -H {{ item }}
+  command: ssh-keyscan {{ deploy_key_repos|join(' ') }}
   register: deploy_key_ssh_keyscan
   changed_when: False
   failed_when: deploy_key_ssh_keyscan|failed or deploy_key_ssh_keyscan.stdout == ""
@@ -72,11 +71,11 @@
   check_mode: no
 
 - name: Add known hosts
-  with_items: '{{ deploy_key_ssh_keyscan.results }}'
+  with_items: '{{ deploy_key_ssh_keyscan.stdout_lines }}'
   known_hosts:
-      key: '{{ item.stdout }}'
+      key: '{{ item }}'
       state: present
-      name: '{{ item.item }}'
+      name: '{{ item|split()[0] }}'
       path: /etc/ssh/ssh_known_hosts
 
 - name: Set premissions for the known hosts file