Deployment Manager 2

Help for older versions available.

Automating the setup of Deployment Manager Agents

When installing large numbers of agents, or using virtual machines with a temporary lifespan, it can be helpful to be able to automate the creation of Deployment Manager agents. Here is one way to do so:

Install an agent manually to serve as a template

First of all, install an agent using the normal manual install process. This will ensure that you know which firewall settings you need to tweak on the target machines, and generate an X509 encryption key which can then be shared among the agents you want to automate.

Note: using this method will allow the agents to impersonate each other if one is compromised. Think carefully before using this technique to share security settings between agents with different levels of security

Run the installer silently on the target machine

Using Microsoft's Group Policy, or your organization's preferred equivalent, execute the agent installer silently on the target machine. If using a script to execute the installer, remember to set the /quiet flag for a silent install.

Update the registry keys on the new agent to the same values as the template machine

Inside "HKEY_LOCAL_MACHINE\SOFTWARE\Red Gate\Deployment Manager\", set the registry keys "Agent.Security.TrustedDmThumbprints" and "Cert-cn=Red Gate Deployment Agent" to be the values of the equivalent keys on your template machine. This will instruct the agent to use the same x509 encryption certificate to encrypt its messages and identify itself to the server. It will also instruct it to accept incoming instructions from the same server.

If you choose to roll out these registry changes using Microsoft's Group Policy, you may find the following template for a custom policy useful:

  1. CLASS MACHINE
  2. CATEGORY "Deployment Manager Agent security"
  3. POLICY "Deployment Manager Security"
  4. EXPLAIN DmAgentHelp
  5. KEYNAME "SOFTWARE\Red Gate\Deployment Manager"
  6. PART server_thumbprint EDITTEXT
  7. VALUENAME "Agent.Security.TrustedDmThumbprints"
  8. END PART
  9. PART agent_certificate EDITTEXT MAXLEN 8192
  10. VALUENAME "Cert-cn=Red Gate Deployment Agent"
  11. END PART
  12. END POLICY
  13. END CATEGORY
  14. [strings]
  15. DmAgentHelp="This configures the Deployment Manager Agent security settings; the server it will accept instructions from and the key it will use to identify itself"

This article about setting up a custom policy in Group Policy may be of help: see part 2: "the hard way" for advice on using the above template.

Register the new Agent with the Deployment Manager

All that remains now is to tell the server where it can find the new machine. You can do this by making a POST request to:

http://<Deployment Manager server address and port>/api/environments/<EnvironmentId>/machines/add

  • EnvironmentId is the ID of the environment to add the machine to. You can view Environment IDs on http://<Deployment Manager server address and port>/api/environments
  • Set the header, X-RedGateDeploymentManager-ApiKey, in the POST request to the API key of the Deployment Manager user. To find your API key, see Finding your API key.

Set the following URL parameters:

Parameter NameExampleDescription
Nametest-agent-01The user-facing name for the agent in the Deployment Manager system.
AgentHostNameagent-01The host name the server should use to communicate with the agent.
AgentPort10301Unless you've specifically set this differently, it should be 10301.
ThumbprintCF8676EE5BEB8AD8864A7AD5D55CBA9B97E86B3EThis should be the value of the thumbprint you used to set up your initial template machine.
TargetTypeMachine

The type of target to create. Allowed values:

    • Machine - a general target machine
    • SqlServerInstance - a SQL Server

 

  • If you're creating a SQL Server target, the following URL parameters are also required:

    Parameter NameExampleDescription
    ServerNamemy-machine\sql2008r2The fully qualified address of the SQL Server instance to add.
    AuthModeSql

    The type of authentication to use when connecting to the SQL Server instance. Allowed values:

      • Sql - use SQL Server authentication (recommended)
      • Integrated - use Windows authentication
    LoginbobSQL Server user with sysadmin permissions. Only required when using SQL authentication.
    Passwordpassword1234SQL Server password. Only required when using SQL authentication.

Example POST request

http://localhost:8050/api/environments/DeploymentEnvironments-1/machines/add?Name=MyMachine&AgentHostName=localhost&AgentPort=10301&Thumbprint=3578820162E0121A6B41F67D9B7FE7BD58E9243F&TargetType=Machine

Using PowerShell to register a new target machine with the Deployment Manager Server

This PowerShell script adds a new target machine to Deployment Manager:

  1. # Input Variables
  2. $DmServer = "localhost"
  3. $DmPort = "8050"
  4. $DmApiKey = "5K1UMAUGDZWKOHWD1TFMRRHK"
  5.  
  6. $EnvironmentId = "DeploymentEnvironments-1"
  7. $Name = "dm-agent-01"
  8. $AgentHostName = "localhost"
  9. $AgentPort = "10301"
  10. $Thumbprint = "3578820162E0121A6B41F67D9B7FE7BD58E9243F"
  11. $TargetType = "Machine"
  12. # ----------------------------
  13.  
  14. $RequestURL = "http://${DmServer}:${DmPort}/api/environments/${EnvironmentId}/machines/add"
  15. $PostData = "Name=${Name}&AgentHostName=${AgentHostName}&AgentPort=${AgentPort}&Thumbprint=${Thumbprint}&TargetType=${TargetType}"
  16. $UrlWithFormData = "${RequestURL}?${PostData}"
  17.  
  18. Write-Host "Sending request to url: $UrlWithFormData"
  19. $response = Invoke-WebRequest -Uri $UrlWithFormData -Method Post -Headers @{"X-RedGateDeploymentManager-ApiKey"="${DmApiKey}"}
  20. Write-Host $response

Didn't find what you were looking for?