Skip to content

Commit

Permalink
Prevent adding duplicate sshd group.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
lassehe committed Jan 25, 2021
1 parent 4cc30a0 commit 8c292f1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions roles/bootstrap/tasks/setup_sshd.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 8c292f1

Please sign in to comment.