My service on CentOS is configured to run under a certain user in its
config file under /etc/systemd/system
:
[Service]
User=buildman
When I am su
ed as buildman, I can run:
systemctl status myservice.service
but if I try to do start
or stop
, it prompts me for password.
If I do:
sudo systemctl status myservice.service
it does not prompt me because I have configured visudo
:
%buildman ALL= NOPASSWD: /bin/systemctl * myservice.service
But why doesn't service stop and start work like status? I would like to enable buildman to execute these service commands without sudo or password.
The primary reason for this is that I need to enable service restart from Jenkins and I ran into problems running sudo from its container, which complained that I needed a "TTY" to run it.
sudo
– amphibient Oct 20 '17 at 17:46