From a52d8014d190abb499ecae21243a7e0c5afe0f1d Mon Sep 17 00:00:00 2001 From: djpbessems Date: Wed, 20 Apr 2022 08:35:27 +0200 Subject: [PATCH] Refactor block --- playbook.yml | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/playbook.yml b/playbook.yml index 6d35051..a79d282 100644 --- a/playbook.yml +++ b/playbook.yml @@ -66,23 +66,20 @@ groups: k3s_ha with_items: "{{ nodes }}" - - 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 - + - name: Scan public keys + ansible.builtin.command: + cmd: "ssh-keyscan -t rsa {{ item.ip }}" + register: publickeys with_items: "{{ nodes }}" + - name: Store public keys + ansible.builtin.known_hosts: + name: "{{ item.item }}" + key: "{{ item.stdout }}" + state: present + path: ~/.ssh/known_hosts + with_items: "{{ publickeys.results }}" + - name: Provision Kubernetes hosts: k3s_ha gather_facts: false