From 8c292f10ebcc941b73bbd85d011b35af702765b1 Mon Sep 17 00:00:00 2001 From: Lasse Heikkila Date: Sun, 24 Jan 2021 19:01:38 +0200 Subject: [PATCH] Prevent adding duplicate sshd group. Check previous sshd group presence, and do not add a duplicate if it already exists, e.g. in case the playbook didn't fully finish on previous round. --- roles/bootstrap/tasks/setup_sshd.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/roles/bootstrap/tasks/setup_sshd.yml b/roles/bootstrap/tasks/setup_sshd.yml index cdc8c3b..362e321 100644 --- a/roles/bootstrap/tasks/setup_sshd.yml +++ b/roles/bootstrap/tasks/setup_sshd.yml @@ -1,3 +1,14 @@ +- name: Check if sshd group exists + telnet: + user: root + password: + login_prompt: "login: " + prompts: + - "[>|#]" + command: + - grep sshd /etc/group + register: sshd_group + - name: Create sshd group telnet: user: root @@ -7,6 +18,7 @@ - "[>|#]" command: - echo "sshd::23:sshd" >> /etc/group + when: sshd_group.output | select('search','sshd::23:sshd') | list | count == 0 - name: Create sshd user telnet: