summaryrefslogtreecommitdiffstats
path: root/roles/ssh/tasks
diff options
context:
space:
mode:
authorAhmed Abdelhalim <[email protected]>2025-11-09 00:46:18 +0100
committerAhmed Abdelhalim <[email protected]>2025-11-09 01:47:00 +0100
commitaa8d8855e0a153245f2ad0832ebeea80af57cbfb (patch)
treeb82a681774708915299f6cf2288c9a8ab836eec3 /roles/ssh/tasks
parent399826fd634e47134feb919b0ee0805035475fc4 (diff)
Refactor scattered known_hosts to be part of the ssh role
Diffstat (limited to 'roles/ssh/tasks')
-rw-r--r--roles/ssh/tasks/main.yml9
1 files changed, 9 insertions, 0 deletions
diff --git a/roles/ssh/tasks/main.yml b/roles/ssh/tasks/main.yml
index 9728e303..76ba7aa5 100644
--- a/roles/ssh/tasks/main.yml
+++ b/roles/ssh/tasks/main.yml
@@ -94,3 +94,12 @@
AllowUsers {{ username }}
notify:
- "Restart ssh"
+
+- name: "Configure known_hosts"
+ ansible.builtin.known_hosts:
+ name: "{{ item.split(' ') | first }}"
+ key: "{{ item }}"
+ path: "{{ ansible_env.HOME }}/.ssh/known_hosts"
+ state: present
+ loop: "{{ ssh_known_hosts }}"
+ when: ssh_known_hosts is defined and ssh_known_hosts | length > 0