cc-ssh: traceback when openssh-server absent
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cloud-init |
Fix Released
|
Low
|
Unassigned |
Bug Description
In minimal cloud images without openssh-server, cloud-init will get the following traceback when the following cloud-config is provided:
```
#cloud-config
ssh_pwauth: true
```
2022-04-19 20:42:32,593 - stages.py[DEBUG]: Running module set-passwords (<module 'cloudinit.
2022-04-19 20:42:32,593 - handlers.py[DEBUG]: start: modules-
2022-04-19 20:42:32,593 - util.py[DEBUG]: Writing to /var/lib/
2022-04-19 20:42:32,593 - helpers.py[DEBUG]: Running config-
2022-04-19 20:42:32,594 - ssh_util.py[DEBUG]: line 1: option PasswordAuthent
2022-04-19 20:42:32,594 - util.py[DEBUG]: Writing to /etc/ssh/
2022-04-19 20:42:32,594 - subp.py[DEBUG]: Running command ['service', 'sshd', 'restart'] with allowed return codes [0] (shell=False, capture=True)
2022-04-19 20:42:32,620 - handlers.py[DEBUG]: finish: modules-
2022-04-19 20:42:32,621 - util.py[WARNING]: Running module set-passwords (<module 'cloudinit.
2022-04-19 20:42:32,621 - util.py[DEBUG]: Running module set-passwords (<module 'cloudinit.
Traceback (most recent call last):
File "/usr/lib/
freq=freq)
File "/usr/lib/
return self._runners.
File "/usr/lib/
results = functor(*args)
File "/usr/lib/
service_
File "/usr/lib/
subp.subp(cmd)
File "/usr/lib/
cmd=args)
cloudinit.
Command: ['service', 'sshd', 'restart']
Exit code: 5
Reason: -
Stdout:
Stderr: Redirecting to /bin/systemctl restart sshd.service
Failed to restart sshd.service: Unit sshd.service not found.
While one could argue that cloud images without openssh-server might have limited utility, there are use cases for slim apps/micro-services that may not rely on this stack and cloud-init should probably cope better in the face of this missing dependency.
While working this issue, let's add a Suggests: openssh-server to debian/control for Deb-based systems.
--- Steps to reproduce problem
cat > ssh_needed.yaml << EOF
#cloud-config
ssh_pwauth: true
EOF
lxc launch ubuntu-daily:focal f1 -c user.user-
lxc exec f1 -- cloud-init status --wait
lxc exec f1 apt remove opensssh-server
# reset PasswordAuthent
lxc exec f1 -- sed -i 's/PasswordAuth
# force clean reboot so cloud-init reruns
lxc exec f1 -- cloud-init clean --logs --reboot
lxc exec f1 -- cloud-init status --wait --long
Changed in cloud-init: | |
importance: | Undecided → Low |
description: | updated |
Look over our reference behavior when missing an expected binary package in this upstream commit[1] which may inform this work for how to approach this use-case as well
https:/ /github. com/canonical/ cloud-init/ commit/ 437cb0a01bc3f87 58caa7b87dcd077 c101a55675