Auto registration of remote agents

As a GoCD administrator, you can auto approve remote agents by using a shared key between the GoCD Agent and GoCD Server.

  • Add an attribute named “agentAutoRegisterKey”, for e.g., agentAutoRegisterKey=”388b633a88de126531afa41eff9aa69e”, in the server configuration fragment, in case it is not present.
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <cruise xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="cruise-config.xsd" schemaVersion="75">
  3. <server agentAutoRegisterKey="388b633a88de126531afa41eff9aa69e">
  4. ...
  5. </cruise>
  • On the remote GoCD Agent machine, create a file named <agent_installation_directory>/config/autoregister.properties. In a native agent installation this file is usually located on /var/lib/go-agent/config/ directory. The config/ folder might not exist, in this case you should create it by yourself.

    This file supports the following properties

KeyRequiredDescription
agent.auto.register.keyyesThe value of the <server/> element’s agentAutoRegisterKey attribute from cruise-config.xml
agent.auto.register.environmentsnoA comma separated list of environments that this agent should be associated with.
agent.auto.register.resourcesnoThis MUST not be set by agents that register as elastic-agents. A comma separated list of resources that this agent should be tagged with.
agent.auto.register.hostnamenoThe name of the agent when it is registered with the server. (Version 15.2.0 onwards)
agent.auto.register.elasticAgent.agentIdnoThis MUST be set by agents that register as elastic-agents. This may contain an identifier of the agent, that the plugin can identify. Can be something like a docker container ID, or AWS instance ID. (Version 16.12.0 onwards)
agent.auto.register.elasticAgent.pluginIdnoThis MUST be set by agents that to register as elastic-agents. This should contain the plugin id of elastic-agent plugin that spins up the agent. (Version 16.12.0 onwards)

Example

  1. agent.auto.register.key=388b633a88de126531afa41eff9aa69e
  2. agent.auto.register.resources=ant,java
  3. agent.auto.register.environments=QA,Performance
  4. agent.auto.register.hostname=Agent01
  5. # if you're using elastic agents, these would be needed as well
  6. agent.auto.register.elasticAgent.agentId=i-123456
  7. agent.auto.register.elasticAgent.pluginId=com.example.aws
  • Now, bringing up the remote agent should automatically register with the GoCD Server without the administrator having to ‘Enable’ the newly added agent and configure its resources and assign it to environments.