Skip to content

Commit

Permalink
fix(node_executor): improve docstrngs
Browse files Browse the repository at this point in the history
  • Loading branch information
blu-base committed Apr 29, 2024
1 parent 6d6b6e1 commit 5be40c5
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions contents/salt_node_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@


def main():
"""
Main function to execute remote commands via Salt-API
This function retrieves necessary data from environment variables provided by Rundeck.
"""
# parse environment provided by rundeck
data_items = [
DataItem('cmd', 'RD_EXEC_COMMAND', 'str'),
Expand Down Expand Up @@ -61,11 +66,10 @@ def main():
'tgt': data['host'],
'fun': 'cmd.run',
'arg': args,
# full return to get retcode
'full_return': True,
'full_return': True, # full return to get retcode
}

# login to api
# login to the API
client = Pepper(api_url=data['url'], ignore_ssl_errors=not data['verify_ssl'])
try:
response = client.login(username=data['user'], password=data['password'], eauth=data['eauth'])
Expand All @@ -74,7 +78,7 @@ def main():
sys.exit(1)
log.debug(f'Logging into API: {response}')

# sending payload
# send payload
try:
response = client.low(lowstate=[low_state])
except PepperException as exception:
Expand All @@ -87,7 +91,7 @@ def main():
data = minion_response.get('ret', 'No response received')
return_code = minion_response.get('retcode', 1)

# rundeck reads stdout
# print response to stdout for Rundeck to pickup
print(data)

# rundeck reads return code
Expand Down

0 comments on commit 5be40c5

Please sign in to comment.