Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Bash script on a remote node doesn't work as expected

424 views
Skip to first unread message

skp15

unread,
Apr 6, 2023, 7:50:11 PM4/6/23
to rundeck-discuss
Hello,

I want to execute a simple bash script (if...else) on remote nodes. I am asking the user to select a operation (start/stop) from the dropdown.

The script looks like:
```
#!/bin/bash
set -x
echo $RD_OPTION_SERVICEOPERATION
if [ "$RD_OPTION_SERVICEOPERATION" = "start" ]; then
    echo "Start."
else
    echo "Stop."
fi
```
It works perfectly executing on the local node but when I execute on a remote node, it is displaying "Stop." What am I doing wrong? The option turns out to return empty.
+ echo
+ '[' '' = start ']'
+ echo Stop.

Any suggestions? What am I doing wrong?

skp15

unread,
Apr 7, 2023, 1:54:31 PM4/7/23
to rundeck-discuss

rac...@rundeck.com

unread,
Apr 10, 2023, 12:29:12 PM4/10/23
to rundeck-discuss
Hi!

Give a chance to this solution.

Regards!

skp15

unread,
Apr 11, 2023, 6:16:49 PM4/11/23
to rundeck-discuss
That's a solution I looked up for adding the nodes. It's still not passing the variable down to the remote nodes.

I was discussing something here - https://stackoverflow.com/questions/75954531/rundeck-bash-script-on-a-remote-node-doesnt-work-as-expected

Still no luck!

What am I doing wrong?

rac...@rundeck.com

unread,
Apr 12, 2023, 9:20:16 AM4/12/23
to rundeck-discuss
Hi,

Could you test using the SSHJ/OpenSSH node executors instead of the default SSH?

Regards.

rac...@rundeck.com

unread,
Apr 12, 2023, 9:21:11 AM4/12/23
to rundeck-discuss
Also,test with the SSHJ or OpenSSH file copiers instead the default SSH.

skp15

unread,
Apr 18, 2023, 4:17:12 PM4/18/23
to rundeck-discuss
Can you please point me to documentation to do so?

rac...@rundeck.com

unread,
Apr 18, 2023, 6:33:27 PM4/18/23
to rundeck-discuss
Hi, Take a look at this.

Basically: go to Project Settings > Edit Configuration > Default Node Executor tab (and Default File copier tab) and change SSH by SSHJ (in both tabs).

Regards!

skp15

unread,
Apr 18, 2023, 8:03:24 PM4/18/23
to rundeck-discuss
I tried that. Same issue. The variable input is not being able to pass down to the remote node.

Is there any alternate approach that will work?

rac...@rundeck.com

unread,
Apr 19, 2023, 12:15:27 PM4/19/23
to rundeck-discuss
Hello, what operating system (and version) is running on your remote nodes?

skp15

unread,
Apr 19, 2023, 12:39:06 PM4/19/23
to rundeck-discuss
Hello,

NAME="CentOS Linux"
VERSION="7 (Core)"

rac...@rundeck.com

unread,
Apr 19, 2023, 1:39:29 PM4/19/23
to rundeck-discuss
Could you test turning off SELINUX on a test remote node?, that could be the root of your issue.

skp15

unread,
Apr 19, 2023, 1:55:18 PM4/19/23
to rundeck-discuss
I just checked the service status:
SELinux status:                 disabled

Not sure what is going wrong. I just want to pass down the variable from user input to remote nodes. It seems so simple but very complicated to implement.

Please suggest something to solve this issue.

rac...@rundeck.com

unread,
Apr 19, 2023, 3:50:55 PM4/19/23
to rundeck-discuss
I found the root cause.

I reproduced your issue. To solve it, follow these steps:

1. Go to Project Settings > System Configuration > Default Node Executor tab.
2. Then, scroll down and mark the "Pass RD_* Variables" checkbox. Take a look.
3. Save and test again.

Hope it helps!

skp15

unread,
Apr 19, 2023, 4:13:51 PM4/19/23
to rundeck-discuss
I already followed that. I thought I had mentioned it above somewhere.


Screenshot 2023-04-19 at 2.04.37 PM.png
I have added AcceptEnv RD_* to the sshd_config on the remote node as well (to the root user).

Is it not accepting because Rundeck job passes the variables as `rundeck` user?

skp15

unread,
Apr 19, 2023, 4:14:42 PM4/19/23
to rundeck-discuss
I am getting Failed: SSHProtocolFailure: failed to send channel request

rac...@rundeck.com

unread,
Apr 19, 2023, 5:05:15 PM4/19/23
to rundeck-discuss
Weird, is your file copier configured as "SCP" could you share your Node Executor / File copier config? A screenshot would help. Thanks.

skp15

unread,
Apr 19, 2023, 6:51:06 PM4/19/23
to rundeck-discuss
Yes, the file copier is configured as "SCP". Should it be something else? Where to find the Node executor config? I configured it using the file option.

Screenshot 2023-04-19 at 4.50.10 PM.png

rac...@rundeck.com

unread,
Apr 20, 2023, 10:10:50 AM4/20/23
to rundeck-discuss
Probably you're facing this, could you check your framework.properties file like this? could you test from a new Rundeck project?

skp15

unread,
Apr 20, 2023, 1:36:49 PM4/20/23
to rundeck-discuss
I don't see `framework.ssh-send-env` in framework.properties file.

Should I add it? or the article says to remove it?

skp15

unread,
Apr 27, 2023, 5:18:33 PM4/27/23
to rundeck-discuss
Hi,

Any suggestions here?

I'd like to get this resolved.

rac...@rundeck.com

unread,
Apr 27, 2023, 5:33:38 PM4/27/23
to rundeck-discuss
Hi,

You can the following approaches to discard the root cause:

1. On the Rundeck server add the SendEnv RD_* line on the /etc/ssh/ssh_config (this allows the ssh client to send these variables to the remote servers) file and restart the ssh / rundeck service.
2. Try creating a new project following this to discard some ssh client/server problems.
3. Could you try using a test remote server and see the differences between configurations? Probably some security config/solution is blocking the ssh variables :/

Regards.

skp15

unread,
May 2, 2023, 2:50:18 PM5/2/23
to rundeck-discuss
Hello,

I do have the SSH private key stored at that path.

I followed these steps but I am get a weird exception now:
Failed to read SSH Private key stored at path: keys/rundeck: org.rundeck.storage.api.StorageException: Not found
Failed dispatching to node ABC: Configuration error: Failed to read SSH Private key stored at path: keys/rundeck

rac...@rundeck.com

unread,
May 2, 2023, 3:41:27 PM5/2/23
to rundeck-discuss

Hi,

The ssh-key-storage-path="keys/rundeck" attribute defined in the node definition refers to a example key stored at keys/rundeck key storage entry. In your case, change that path by your own private key path (stored in your Rundeck instance Key Storage).

Regards.

skp15

unread,
May 2, 2023, 4:18:25 PM5/2/23
to rundeck-discuss
I have the exactly same path setup in my rundeck instance.
Screenshot 2023-05-02 at 2.17.46 PM.png

Do I have to update anywhere?

rac...@rundeck.com

unread,
May 2, 2023, 6:35:29 PM5/2/23
to rundeck-discuss

Hi,

Your key is stored on keys/rundeck/id_rsa, the example is defined as keys/rundeck (in this case “rundeck” is the key, not a directory).

Change the ssh-key-storage-path attribute to: ssh-key-storage-path=keys/rundeck/id_rsa

Regards.

skp15

unread,
May 2, 2023, 6:49:21 PM5/2/23
to rundeck-discuss
It is working now. But I am back to the root problem - Failed: SSHProtocolFailure: failed to send channel request

`uname -a` command works when I disable Pass RD_* Variables

This error above is when the RD_* is enabled on the project.

On the Rundeck server add the SendEnv RD_* line on the /etc/ssh/ssh_config but there's no ssh service running on Rundeck to restart.

I am really confused what to do.

rac...@rundeck.com

unread,
May 2, 2023, 7:15:12 PM5/2/23
to rundeck-discuss
Did you check against another test ssh sever? (virtualized, dockerized, etc). In that way you can compare configurations.

It seems a problem with your target server, take a look at these answers.

Greetings.
Reply all
Reply to author
Forward
0 new messages