I am trying to clear a hands on in HackerRank, where the task is to stop and start the service named ssh using service module. I have used the below code.
- name: "Stop ssh"
service:
name: ssh
state: stopped
- name: "start ssh"
service:
name: ssh
state: started
Can you please guide me to clear the hands on.
The service handling ssh on Linux is called
sshd
like a lot of other services, where thed
stands for daemon.So your correct tasks would be:
This said, since Ansible connects through ssh, I am unsure how this will really react when the service is stopped.
Most of the linux services, though do also have a
restart
instruction, that you can also use in Ansible, with thestate
valuerestarted
.