From c8027778679ff31f5e97bd80e5d0514c61147155 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Wed, 16 Nov 2022 16:10:10 +0100 Subject: [PATCH 1/2] Add root keys for all users And not just the last user. --- roles/ubuntu_base/tasks/users.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/roles/ubuntu_base/tasks/users.yml b/roles/ubuntu_base/tasks/users.yml index da87b4e..dad2a2a 100644 --- a/roles/ubuntu_base/tasks/users.yml +++ b/roles/ubuntu_base/tasks/users.yml @@ -18,6 +18,5 @@ - name: "Add ssh authorized_keys to root user" authorized_key: user: "root" - key: "{{ item.ssh_keys | join('\n') }}" + key: "{{ users | default([]) | map(attribute='ssh_keys') | join('\n') }}" exclusive: true - loop: "{{ users | default([]) }}" -- 2.43.4 From 5a54eb6b1ef2d53a2647b4f60e12d07afc8e949a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Wed, 16 Nov 2022 16:24:22 +0100 Subject: [PATCH 2/2] Flatten the list --- roles/ubuntu_base/tasks/users.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/ubuntu_base/tasks/users.yml b/roles/ubuntu_base/tasks/users.yml index dad2a2a..010666e 100644 --- a/roles/ubuntu_base/tasks/users.yml +++ b/roles/ubuntu_base/tasks/users.yml @@ -18,5 +18,5 @@ - name: "Add ssh authorized_keys to root user" authorized_key: user: "root" - key: "{{ users | default([]) | map(attribute='ssh_keys') | join('\n') }}" + key: "{{ users | default([]) | map(attribute='ssh_keys') | flatten | join('\n') }}" exclusive: true -- 2.43.4