I have a GCE instance that I push code to using Cloud Build. I need to restart services on that VM once the code has been pushed. Here's what my Cloud Build YAML looks like:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
for d in *; do
gcloud compute scp $d user@instance-1:/path/to/directory --zone=asia-south1-a --recurse
done
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
gcloud compute ssh user@instance-1 --zone=asia-south1-a --command="service uwsgi restart"
timeout: 1200s
While the first step works fine, while trying to restart the service, I receive the following error:
Already have image (with digest): gcr.io/cloud-builders/gcloud
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=Hello cookie=1 reply_cookie=0 error=n/a
Got message type=method_return sender=org.freedesktop.DBus destination=:1.3477 object=n/a interface=n/a member=n/a cookie=1 reply_cookie=1 error=n/a
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=2 reply_cookie=0 error=n/a
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=AddMatch cookie=3 reply_cookie=0 error=n/a
Calling manager for ReloadUnit on uwsgi.service, replace
Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=ReloadUnit cookie=4 reply_cookie=0 error=n/a
Failed to reload uwsgi.service: Interactive authentication required.
See system logs and 'systemctl status uwsgi.service' for details.
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RemoveMatch cookie=5 reply_cookie=0 error=n/a
Sent message type=method_call sender=n/a destination=org.freedesktop.DBus object=/org/freedesktop/DBus interface=org.freedesktop.DBus member=RemoveMatch cookie=6 reply_cookie=0 error=n/a
Sent message type=method_call sender=n/a destination=org.freedesktop.systemd1 object=/org/freedesktop/systemd1 interface=org.freedesktop.systemd1.Manager member=ReloadUnit cookie=4 reply_cookie=0 error=n/a
Failed to reload uwsgi.service: Interactive authentication required.
See system logs and 'systemctl status uwsgi.service' for details.
I've tried disabling the interactive authentication mechanism as mentioned here and here but that hasn't worked. Please help.