A runbook process can run steps, which include scripts, on the Octopus Server, a worker, or a deployment target. Up until this point in the tutorial the runbook process for Hello Runbook only ran on the Octopus Server. With the deployment target(s) added on the previous page, we can now update the runbook process to run on deployment targets.
- Click Runbooks on the left menu.
- Click Hello Runbook in the list of runbooks.
- Click Process in the runbook menu.
- Click ADD STEP.
- Select the Script tile to filter the types of steps.
- Scroll down and click ADD on the Run a Script tile.
- Change Name of the script to be “Run a script on deployment targets” for the script
- Leave the Enabled check-box ticked.
- In the Execution Location section change the option to be Run on each deployment target.
- In the Target Tags section change the tag to be
Hello-World
.
Not all steps can run on deployment targets. A step missing the option Target Tags indicates that step must run on the Octopus Server or a on a worker
- Scroll down to the Script, select your script language of choice and enter the following script in the Inline Source Code section:
PowerShell
Write-Host $OctopusParameters["Helloworld.Greeting"]
Write-Host $OctopusParameters["Octopus.Machine.Name"]
Bash
greeting=$(get_octopusvariable "Helloworld.Greeting")
echo $greeting
machineName=$(get_octopusvariable "Octopus.Machine.Name")
echo $machineName
- Click SAVE
- Click RUN… and select an environment to run on.
Not all scripts should run on a deployment target. A rule of thumb is a script should target a deployment target if it needs to modify something specific on that target, such as restarting a service, or installing a web server. If you need to manage PaaS targets, K8s clusters, or database servers, the recommendation is to run the script on a worker.
The next step will publish the runbook so it can used by triggers and users have a known version to run.
Further Reading
For further reading on runbook processes and what is possible please see:
Help us continuously improve
Please let us know if you have any feedback about this page.
Page updated on Tuesday, July 30, 2024