Skip to content

Commit

Permalink
Patch to manage issue cea-hpc#66. This adds the option ssh_user in th…
Browse files Browse the repository at this point in the history
…e configuration file.
  • Loading branch information
MarbolanGos committed Jul 29, 2024
1 parent 29aa934 commit e1cca13
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
11 changes: 11 additions & 0 deletions conf/samples/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,14 @@ services:
on_gateway:
remote: False
cmd: /bin/gw_action
#
# Run a command with a non logged in user
#
# The SSH command will be executed with a specific user
#
non-logged-in-user:
desc: Connect via a non logged in user
ssh_user: "admin"
actions:
status:
cmd: id
3 changes: 3 additions & 0 deletions lib/MilkCheck/Engine/Action.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ def perform_action(self, action):
if not self.dryrun:
command = action.command

if action.ssh_user:
self._master_task.set_info("ssh_user", action.ssh_user)

if action.mode == 'exec':
wkr = ExecWorker(nodes=nodes, handler=ActionEventHandler(action),
timeout=action.timeout, command=command,
Expand Down
6 changes: 6 additions & 0 deletions lib/MilkCheck/Engine/BaseEntity.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,9 @@ def __init__(self, name, target=None, delay=0):
# Tags the entity. The tags set define if the entity should run
self.tags = set()

# ssh_user
self.ssh_user = None

def filter_nodes(self, nodes):
"""
Add error nodes to skip list.
Expand Down Expand Up @@ -731,6 +734,7 @@ def inherits_from(self, entity):
self.delay = self.delay or entity.delay
self.maxretry = self.maxretry or entity.maxretry
self.tags = self.tags or entity.tags
self.ssh_user = self.ssh_user or entity.ssh_user

def fromdict(self, entdict):
"""Populate entity attributes from dict."""
Expand Down Expand Up @@ -758,6 +762,8 @@ def fromdict(self, entdict):
self.desc = prop
elif item == 'tags':
self.tags = set(prop)
elif item == 'ssh_user':
self.ssh_user = prop
elif item == 'variables':
for varname, value in prop.items():
self.add_var(varname, value)
Expand Down

0 comments on commit e1cca13

Please sign in to comment.