Skip to content

Commit

Permalink
Refactor and fix SSH service restart on OSMount worker SSH env config…
Browse files Browse the repository at this point in the history
…uration

On newer Ubuntu (starting with 24.04) Server images, `sshd` service name has
been changed to `ssh`. This patch handles this rename and refactors it into
the base OSMount class, in order for it to be picked up for all Linux OSMount
minions.
  • Loading branch information
Dany9966 committed Jul 31, 2024
1 parent e735358 commit afa8422
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
12 changes: 10 additions & 2 deletions coriolis/osmorphing/osmount/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
from coriolis import exception
from coriolis import utils


LOG = logging.getLogger(__name__)

MAJOR_COLUMN_INDEX = 4
Expand Down Expand Up @@ -96,7 +95,16 @@ def setup(self):
self._connect()

def _allow_ssh_env_vars(self):
pass
self._exec_cmd('sudo sed -i -e "\$aAcceptEnv *" /etc/ssh/sshd_config')
try:
utils.restart_service(self._ssh, "sshd")
except exception.CoriolisException:
# Newer Ubuntu distros renamed this service to `ssh`
LOG.warning(
"Could not restart service sshd. Attempting to restart ssh "
"service")
utils.restart_service(self._ssh, 'ssh')
return True

def _exec_cmd(self, cmd, timeout=None):
if not timeout:
Expand Down
5 changes: 0 additions & 5 deletions coriolis/osmorphing/osmount/redhat.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,3 @@ def setup(self):
self._exec_cmd("sudo -E yum install -y lvm2 psmisc")
self._exec_cmd("sudo modprobe dm-mod")
self._exec_cmd("sudo rm -f /etc/lvm/devices/system.devices")

def _allow_ssh_env_vars(self):
self._exec_cmd('sudo sed -i -e "\$aAcceptEnv *" /etc/ssh/sshd_config')
utils.restart_service(self._ssh, "sshd")
return True
5 changes: 0 additions & 5 deletions coriolis/osmorphing/osmount/ubuntu.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,3 @@ def setup(self):
"install lvm2 psmisc -y")

self._exec_cmd("sudo modprobe dm-mod")

def _allow_ssh_env_vars(self):
self._exec_cmd('sudo sed -i -e "\$aAcceptEnv *" /etc/ssh/sshd_config')
utils.restart_service(self._ssh, "sshd")
return True

0 comments on commit afa8422

Please sign in to comment.