From fc0c0c503601a773c574f062d9ea3a26cfea1131 Mon Sep 17 00:00:00 2001 From: Sam Al-Sapti Date: Tue, 15 Nov 2022 19:57:17 +0100 Subject: [PATCH] Always update password and overwrite keys --- roles/ubuntu_base/tasks/users.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/roles/ubuntu_base/tasks/users.yml b/roles/ubuntu_base/tasks/users.yml index 4e9954cf..0fbfe7ef 100644 --- a/roles/ubuntu_base/tasks/users.yml +++ b/roles/ubuntu_base/tasks/users.yml @@ -4,22 +4,20 @@ name: "{{ item.name }}" comment: "{{ item.comment }}" password: "{{ item.password }}" - update_password: "on_create" - groups: "{{ item.groups }}" + groups: "{{ item.groups }}" + update_password: "always" loop: "{{ users | default([]) }}" - name: "Add ssh authorized_keys" authorized_key: - user: "{{ item.0.name }}" - key: "{{ item.1 }}" - with_subelements: - - "{{ users | default([]) }}" - - keys + user: "{{ item.name }}" + key: "{{ item.keys | join('\n') }}" + exclusive: true + loop: "{{ users | default([]) }}" - name: "Add ssh authorized_keys to root user" authorized_key: user: "root" - key: "{{ item.1 }}" - with_subelements: - - "{{ users | default([]) }}" - - keys + key: "{{ item.keys | join('\n') }}" + exclusive: true + loop: "{{ users | default([]) }}"