Skip to content

Commit

Permalink
warn and exit if ssh-import-id not available
Browse files Browse the repository at this point in the history
  • Loading branch information
holmanb committed Apr 14, 2022
1 parent e356062 commit eb682cf
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cloudinit/config/cc_ssh_import_id.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,19 @@
from cloudinit import subp, util
from cloudinit.distros import ug_util

SSH_IMPORT_ID = "ssh-import-id"

# https://launchpad.net/ssh-import-id
distros = ["ubuntu", "debian"]


def handle(_name, cfg, cloud, log, args):

if cfg.get('ssh_import_id') and subp.which(SSH_IMPORT_ID):
log.warn(
"ssh-import-id is not installed, but module ssh_import_id is "
"configured. Skipping module."
)
return
# import for "user: XXXXX"
if len(args) != 0:
user = args[0]
Expand Down Expand Up @@ -100,7 +107,7 @@ def import_ssh_ids(ids, user, log):
except KeyError as exc:
raise exc

cmd = ["sudo", "-Hu", user, "ssh-import-id"] + ids
cmd = ["sudo", "-Hu", user, SSH_IMPORT_ID] + ids
log.debug("Importing SSH ids for user %s.", user)

try:
Expand Down

0 comments on commit eb682cf

Please sign in to comment.