This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.

āš ļø We've moved!

Hi there!

To reduce project dependency on 3rd party paid services the StackStorm TSC has decided to move the Q/A from this forum to Github Discussions. This will make user experience better integrated with the native Github flow, as well as the questions closer to the community where they can provide answers.

Use šŸ”— Github Discussions to ask your questions.

Need to implement stackstorm actions

Hi,

I am new to stackstorm and Kindly help me on the below requirement.

Manual Process:
step1: We are logging into a server using user credentials
step2: switching to docker user using: sudo su - docker (it is not asking password)
Step3: Now executing the commands:
systemctl start docker
systemctl stop docker
systemctl restart docker

I know we can use remote shell command runner type for the action but how to switch to docker user from user and run above commands.

@Narendra4st2

like remote you can use the remote_sudo action from the core pack. remote_sudo will run the command as sudo. Iā€™m guessing something like this should work for you.

st2 run core.remote_sudo cmd="su - docker; <commands/script that you might want to execute>" username="<remote-host-ssh-username>"  password="<remote-host-ssh-password>" hosts="localhost/remote-host"

If passwordless sudo is not enabled then you can also pass the sudo_password to the action. Hope this helps.

2 Likes

@Sheshagiri Thank you it is working.

2 Likes