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 a deployment target.
- In the On Target In Roles section change the role to be
Not all steps can run on deployment targets. A step missing the option On Target In Roles 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:
Write-Host $OctopusParameters["Helloworld.Greeting"] Write-Host $OctopusParameters["Octopus.Machine.Name"]
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.
For further reading on runbook processes and what is possible please see:
Need support? We're here to help.