Skip to content

Commit

Permalink
change ssh restart method for ubuntu 23
Browse files Browse the repository at this point in the history
  • Loading branch information
rikukissa committed Dec 18, 2023
1 parent 4ab046a commit 7a3e48a
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions infrastructure/server-setup/tasks/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,28 @@
register: check_result
ignore_errors: yes

- name: Restart SSH service
# Ubuntu 22.10
- name: Check if sshd service exists
command: systemctl status sshd
register: sshd_status
ignore_errors: yes

- name: Restart SSH service (sshd)
service:
name: sshd
state: restarted
when: check_result.rc == 0
when: sshd_status.rc == 0
become: yes

# Ubuntu 23.10
- name: Check if ssh service exists
command: systemctl status ssh
register: ssh_status
ignore_errors: yes

- name: Restart SSH service (ssh)
service:
name: ssh
state: restarted
when: ssh_status.rc == 0 and sshd_status.rc != 0
become: yes

0 comments on commit 7a3e48a

Please sign in to comment.