On GCE platform I have a Managed Instance Group for which a template is assigned.
The template has a startup script (bash) that pulls the latest code from a git repo and installs a few requirements.
Occasionally the startup script fails to update the code or fails to update the requirements.
In this case I would like to abort the startup.
What would be the correct way to go about this?
How do I signal the error?
Can I get the machine to restart or are there other options?
Related
Is there a way to create a problem metric in Dynatrace using a shell script that can be executed from the Linux server?
Here, Problem metric means,
Let's assume that we are using a shell script to check the status of deployed services on the Linux Server.
Then,
That Shell Script should be able to be called by Dynatrace
And, based on Shell Script's response, should be able to create Problem.
What do you mean by 'problem metric'?
You can create metrics via the Metric API and Problems via the Events API
You can call either endpoint from a shell script on linux. If there is a OneAgent on the system you could also use an extension.
I have configured Azure Release pipeline for my deployment. But I want to run Mysql scripts on Mysql Sever using azure devops tasks, can someone help me if there is a best way to run the scripts ?
0- what task should I use from azure marketplace ?
1- should I run all scripts in one task or each script as a separate task ?
2- how to wait while script is running ?
MySQL Toolkit for Windows is a VSTS / TFS extension and contains helpful tasks for build and release definition for MySQL servers. You can run ad-hoc MySQL command, script or scripts collection on Windows Agents including Windows Hosted Agents (Linux Agents not supported).
In addition, you can add a step to run a PowerShell/batch script to execute the SQL script, and you can also create a custom build task and publish it to VSTS.
BTW, you could add PowerShell Sleep function to wait while script is running.
Update>>You could use Copy Files task to copy files from a source folder to a target folder using match patterns.
I am looking to run a script once during VM instantiation. The startup script in the compute engine template runs every time the VM is started. Say for e.g. I have to install gnome desktop on linux host, I don't want to include that in startup script. Rather I am looking for something that runs once whet he host is created. Of course, I want this automated. Is it possible to do this?
Edit: I am trying to achieve this in Linux OS.
As the documentation [1], if we create startup scripts on a compute engine instance then the instances perform automated tasks “every time” the instance boots up.
To run startup script once, the most basic way is to use a file on the filesystem to flag when the script has been run or you could use the instance metadata to store the state.
For example via:
INSTANCE_STATE=$(curl http://metadata.google.internal/computeMetadata/v1/instance/attributes/state -H "Metadata-Flavor: Google")
Then set state = PROVISIONED after running the script etc.
But it is a good idea to have your script check specifically if the actions it is going to do have already been done and handled accordingly.
Another option, in your startup script you can have it removed the startup-script metadata at the end from the host instance
[1] https://cloud.google.com/compute/docs/startupscript
[2] https://cloud.google.com/compute/docs/storing-retrieving-metadata
I've set up startup scripts for all of my instances, so that when I reboot one, it updates itself to the latest version of whatever it's running. Now I want to do multiple of those via one script, one single button push. It works by just rebooting all relevant instances, but I want to see the output of the startup scripts.
From here: https://cloud.google.com/compute/docs/startupscript#rerunthescript - I've found out that, on Debian machines, triggering a startup script by itself without rebooting a machine is done via sudo google_metadata_script_runner --script-type startup, and that all output from the startup script goes to /var/log/daemon.log. Is there any way to set the startup scripts to output directly to stdout?
As ZachB mentioned, startup scripts on Google Compute Engine will output to the serial port which you can view in the Cloud Console or on the command line with the gcloud tool. The following docs explain in more detail how to view the serial port output:
Interacting with the Serial Console
https://cloud.google.com/compute/docs/instances/interacting-with-serial-console
(Navigate to 'VM Instances' -> instance name -> 'Serial port' -> 'Connect to serial port')
gcloud compute instances get-serial-port-output
https://cloud.google.com/sdk/gcloud/reference/compute/instances/get-serial-port-output
gcloud compute instances get-serial-port-output NAME [--port=PORT] [--zone=ZONE] [GLOBAL-FLAG …]
My app (rails a ruby-1.9) is currently serving a 503.
All the rhc commands don't work. I cannot even do rhc ssh <my-app>.
I tried to restart the app from the web, it gives me this:
Unable to perform action on app object. Another operation is already running.
Unhandled exception reference #78227deaed799856c3c386744c8be9c4: Unable to perform action on app object. Another operation is already running.