Yours local user should be a "sudoer" without a password
$ sudo usermod -aG sudo <username>
Then put %sudo ALL=(ALL:ALL) NOPASSWD: ALL to the end of /etc/sudoers
$ bundle installWe use Redis to store timestamp when config was updated last time
Install:
sudo apt-get -y install redis-serverRun"
sudo service redis-server$ bundle exec rackup$ bundle exec rspecIt's API tools, so we have several endpoints
Return timestamp when config for :service was last updated
GET api/v1/:service/last_requestReceive json with updates for config. Updates config and reboot :service, also saves current time via timestamp into Redis.
POST api/v1/:serive/configReboot :service
PUT api/v1/:service/rebootWe use jwt to authenticate users. Right now token hardcoded. To get access to API add this header
"Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJzdWNjZXNzIjp0cnVlfQ."curl -i -X GET -H "Content-Type: application/json" -H "Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJzdWNjZXNzIjp0cnVlfQ." "localhost:9292/api/v1/services/nginx/last_request"
curl -i -X POST -d '{"config": {"user": "www-data", "worker_processes": "10"}}' -H "Content-Type: application/json" -H "Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJzdWNjZXNzIjp0cnVlfQ." "localhost:9292/api/v1/services/nginx/config"
curl -i -X POST -d "" -H "Content-Type: application/json" -H "Access-Token: eyJ0eXAiOiJKV1QiLCJhbGciOiJub25lIn0.eyJzdWNjZXNzIjp0cnVlfQ." "localhost:9292/api/v1/services/nginx/reboot"