octopus-deploy-cookbook icon indicating copy to clipboard operation
octopus-deploy-cookbook copied to clipboard

Support workers tentacle types

Open NootN00t opened this issue 5 years ago • 2 comments
trafficstars

It would be great if a tentacle could be installed and registered as a worker with Octo server.

NootN00t avatar Jan 03 '20 14:01 NootN00t

Have been working on my own implementation which results in something like this in tentacle.rb:

action :register_worker do
  service_name = service_name(new_resource.instance)

  verify_server(new_resource.server)
  verify_api_key(new_resource.api_key)
  verify_workerpool(new_resource.workerpool)

  powershell_script "register-#{new_resource.instance}-worker" do
    action :run
    cwd tentacle_install_location
    code <<-EOH
      .\\Tentacle.exe register-worker `
        --name "#{new_resource.tentacle_name}" `
        --server "#{new_resource.server}" `
        --apiKey "#{new_resource.api_key}" `
        #{option('workerpool', new_resource.workerpool)} `
        #{option_flag('force', new_resource.forced_registration)} `
        --console
      #{catch_powershell_error('Registering Worker')}
    EOH
    not_if { tentacle_exists?(new_resource.server, new_resource.api_key, tentacle_thumbprint(new_resource.config_path), 'workers') }
    notifies :restart, "windows_service[#{service_name}]", :delayed
  end

  windows_service service_name do
    action :nothing
  end
end

Thought it would make more sense to have a separate set of actions defined in case you wanted a worker and then wanted to remove at a later date but keep the underlying tentacle install.

Did consider a whole new resource type but thought given that they are so related it made sense to append to the existing code.

Happy to PR with all the changes once the build is back up and running and get some feedback

NootN00t avatar Jan 03 '20 14:01 NootN00t

Is there any chance of getting this functionality included in the cookbook please? We are still relying on a internal edited copy of this repository to enable us to register workers using the code above. This has just tripped us up due to a change to the order of the create instance and certificate, so it would be good to remove the dependency on the internal repository if possible.

geoff-carr-bzy avatar Jul 28 '23 10:07 geoff-carr-bzy