patternMinor
GitHub Actions Runner execute commands with sudo GitHub Actions
Viewed 0 times
actionscommandswithgithubrunnersudoexecute
Problem
I have a GitHub action set on self hosted Ubuntu VPS on Linode.
I ran
But still when I push on the server the following error occurs.
I also need to set up 2 more runners on the same server and same setup.
I ran
sudo ./svc.sh install and then ./svc.sh start. The runner is up and working but I have a command in my yaml file that needs to run as sudo. I have this command in sudoers file to run without sudo%sudo ALL= NOPASSWD: /bin/systemctl restart twentydb.serviceBut still when I push on the server the following error occurs.
sudo: a terminal is required to read the password; either use the -S option to read from standard input or configure an askpass helpername: restart the service
run: |
sudo systemctl restart twentydbI also need to set up 2 more runners on the same server and same setup.
Solution
airtower-luna from GitHub community answered it here and it worked for me
Answer pasted below:
The command in your workflow file is not the same as the one in your sudoers file, sudo doesn’t know they are functionally equivalent. Use twentydb.service in the workflow, too.
Also, is the user your runner runs as in the sudo group? If not, that entry won’t apply to it. However, I’d suggest using a separate entry for the user rather than adding the runner to the sudo group.
Answer pasted below:
The command in your workflow file is not the same as the one in your sudoers file, sudo doesn’t know they are functionally equivalent. Use twentydb.service in the workflow, too.
Also, is the user your runner runs as in the sudo group? If not, that entry won’t apply to it. However, I’d suggest using a separate entry for the user rather than adding the runner to the sudo group.
Context
StackExchange DevOps Q#11961, answer score: 3
Revisions (0)
No revisions yet.