Execute systemctl commands from nodered on remote system? Since I am not running NR under root context, trying to find ways to do this. For example via exec node:
There are 2 possible things that could cause this as far as I can see.
The most probable is that it is sudo asking for the password. You are directly triggering sudo on the node-red server so you need to ensure that the command you are triggering is the one you have put into sudoers. However, I'm not sure if you also trigger sudo on the remote system as well? If so, perhaps you need to add the command into that sudoers config as well?
The less likely reason would be that the host request is trying to ask for the password for the nodered user on the remote?
Are you actually running Node-RED on the remote server? If so, it would be easier possibly to have a flow on that server itself that restarts bind9 and then trigger that flow either via a webhook or an MQTT message.
And my workaround seems to work... but does not work. I get no error, I get all the response prompts/text I expect to see... but the result is a type of 'no-op' in that the command appears to run, execute, but systemd still shows the service as dead, offline. Result code is 0, which denotes correct execution... well.
If I run the exact command locally works. If I run the exact command on a remote server, it works. It is only when I run it via NR it appears to work but does not... interesting. Somewhere some way, I think I missed something.
As for using MQTT... I could also have a small python script, i.e. a listener, work as well, which would let me avoid additional copy of NR. Done this before.
Nuts... it apparently is working consistently... I had a 'index' typo, so when I thought I was testing 'service 1' I as actually restarting 'service 0'... LOL. The test inject node was wrong.