October 1, 2015
Guest post by Anthony Shaw, Head of Innovation, ITaaS at Dimension Data
This blog post will take you through the integration pack for OctopusDeploy and give you some example actions and rules to integrate with other packs.
Octopus Deploy is an automated deployment tool for .NET and Windows environments. It has gained significant popularity amongst the .NET development community for it’s ease of use and integration into the Microsoft development ecosystem. OctopusDeploy enables users to automate deployment of applications, packages and tools to Windows environments.
Octopus Deploy provides a rich system for Windows application deployments, but this is typically part of a wider DevOps process. Unlike StackStorm, it does not support closed-loop monitoring, remediation or infrastructure configuration and building, it does not integrate into configuration management tools (nor claim to). If you want to integrate OctopusDeploy from another tool, as part of a DevOps or environment tool you could write custom integrations from each tool to the Octopus API or you could simply use StackStorm as the go-between to join your systems together. Imagine the possible integration scenarios:
The Octopus Deploy pack for StackStorm enables you to drive those scenarios with no additional development. StackStorm packs consist of 2 components:
create_release
deploy_release
get_releases
add_machine
new_release_sensor
new_deployment_sensor
From the StackStorm console, use the packs.install
task to download and install the pack:
st2 pack install octopusdeploy
StackStorm packs by convention each have a configuration file for server-wide properties. The Octopus pack needs to be configured first, update /opt/stackstorm/packs/octopusdeploy/config.yaml
to setup the connection to Octopus. You need to issue an Octopus Deploy API key to integrate the pack. The documentation for this is available on the Octopus Website. Within config.yaml
, populate the example properties with your test instance
api_key
– an API key generated in Octopus for your userhost
– the hostname of your Octopus server e.g. octopus.mydomain.comport
– the port your API service is running on, 443 by default Now, restart the StackStorm services to reload the configurationst2ctl restartNow you can test in the UI to get releases and versions. Select the actions pane and choose get_releases. Enter the project ID of one of your existing projects and execute the action.
Got it? Ok, lets look at a more concrete example. Let’s create a basic rule that detects when a new release or deployment is raised and posts a message in Slack with some details. I’m going to assume you already have a Slack account, if you haven’t already installed the Slack pack you can do so now
st2 pack install slack
Then update /opt/stackstorm/configs/slack.yaml with an authentication token from Slack using the instructions here.
From the console, create a new rule definition using this format:
{ "name": "octopus_releases", "tags": [], "enabled": true, "trigger": { "type": "octopusdeploy.new_release", "parameters": {}, "pack": "octopusdeploy" }, "criteria": {}, "action": { "ref": "slack.post_message", "parameters": { "username": "anthonypjshaw", "message": "{{trigger.author}} created a release {{trigger.version}} in octopus project {{trigger.project_id}} with notes {{trigger.release_notes}}", "channel": "#releases" } }, "pack": "octopusdeploy" }
Import the rule into StackStorm by using the rule create command.
st2 rule create release_rule.json
Back in the UI you will see your new rule,
When someone has created a new release, you will see the rule action in the History pane:
To detect new deployments, create a new rule
{ "name": "octopus_deployments", "tags": [], "enabled": true, "trigger": { "type": "octopusdeploy.new_deployment", "parameters": {}, "pack": "octopusdeploy" }, "criteria": {}, "action": { "ref": "slack.post_message", "parameters": { "username": "anthonypjshaw", "message": "{{trigger.author}} created a deployment {{trigger.version}} in octopus project {{trigger.project_id}}", "channel": "#releases" } }, "pack": "octopusdeploy" }
And then in Slack you should see a live feed of new releases and deployments within the “Releases” channel.
Now you’re familiar with the pack and the potential for other integration scenarios, check out some of the other actions you could run in packs like: