diff --git a/playbook.yml b/playbook.yml index 2342220..6d35051 100644 --- a/playbook.yml +++ b/playbook.yml @@ -66,9 +66,21 @@ groups: k3s_ha with_items: "{{ nodes }}" - - name: Store public keys in 'known_hosts' - ansible.builtin.command: - cmd: ssh-keyscan -t rsa {{ item.ip }} >> ~/.ssh/known_hosts + - name: Add new VM's as 'known_hosts' + block: + + - name: Scan public key + ansible.builtin.command: + cmd: "ssh-keyscan -t rsa {{ item.ip }}" + register: publickey + + - name: Store public key + ansible.builtin.known_hosts: + name: "{{ item.name }}" + key: "{{ publickey.stdout }}" + state: present + path: ~/.ssh/known_hosts + with_items: "{{ nodes }}" - name: Provision Kubernetes