Our small team here in London is going through a transformation, albeit a slow one. One from a centralised monolith to smaller services that make up something bigger, from process as a gateway to process as an enabler, etc.

To help drive towards this vision I've been working a good amount on the infrastructure side of things. I'm not saying I'm a networking/infrastructure god, like the people that support us, but I have been learning Chef, Ruby (ewww), basic networking, how all the pieces fit together, along with a few others.

Our build pipelines use Octopus Deploy, which is optimised for deployments to Windows. Recently, around v3 or a little before, they added support for Linux deployments via SSH.

That's great, but after setting up our CentOS based Chef cookbook, I found there were no cookbooks for Octopus which supported Linux; they only seem support Windows.

Thus, I created a cookbook, available via Chef Supermarket, that will automatically register the node with the Octopus Deploy server.

It's super simple in the fact that it just uses the Octopus API. Let's get into a small example.

Prerequisites

If you're using Octopus < v3.16, you will need to install mono on your node. There's a cookbook for that, or just add the yum repo and go for it.

Registering Your Node

metadata.rb

# add dependency
depends 'octopus_ssh_tentacle_registration'  

some_recipe.rb

# use the LWRP
register_ssh_octopus_tenacle 'sample-server' do  
  server_url 'https://my.octopus.server.me'
  api_key 'Octopus API Key'
  ssh_account_id 'Account ID of SSH user being used to connect to the boxes'
  environments ['environments', 'to put this', 'box in']
  roles ['roles this', 'box has']
end  

We use Vault to get these values, but you can also use data bags. Try not to hardcode the API key, horrible practice.

Note: This is safe to run multiple times. If your node has already been registered, it will not be registered again.

Output

You should either see some inform messages saying:

  1. Your node has been registered with the server
  2. Your node has already been registered with the server, it will not be registered again
  3. An API error occurred with the request and response data

Happy hunting!