Inedo Community Forums Forums
    • Recent
    • Tags
    • Popular
    • Login

    Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.

    If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!

    Create new server in Otter using API

    Scheduled Pinned Locked Moved Support
    apibuildmasterotter
    3 Posts 3 Posters 19 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      pdavis_9878
      last edited by

      I am trying to create a new server in Otter using PowerShell and the guidance in the documentation. Since there is no example, it has complicated things in that the page (which I am using the name of the server I am trying to create) returns an error of "not found". The URL I am using is:

      https://<my server's URL>/servers/create/<server name>>?key=<my api key>

      I am passing a json body with the parameters as described in the documentation using PowerShell's Invoke-RestMethod Cmdlet with a method of Post. What is it that I need to do to create this server?

      Product: BuildMaster
      Version: 6.0.4

      1 Reply Last reply Reply Quote 0
      • J Offline
        jharbison
        last edited by

        I believe your url should look like https://<my server's URL>/api/infrastructure/servers/create/<server name>?key=<my api key>

        1 Reply Last reply Reply Quote 0
        • P Offline
          pcamelio_0469
          last edited by

          Hello Paul

          Here is the powershell script we are using.
          It is running from the server as a part of our init server script.
          We deploy the Otter/BuildMaster Agent and we run the script .

          Hope this help

          Regards
          Philippe

          Param(
          
             [Parameter(Mandatory=$false)]
             [string]$API = "https://#OTTERHOST#/api", 
             
             [Parameter(Mandatory=$false)]
             [string]$SERVEUR = $env:computerName
          
          ) #end param
          
          # Extract AESKey
          [xml]$XmlDocument = Get-Content -Path "C:\Program Files\InedoAgent\InedoAgentService.exe.config"
          $AESKey=($XmlDocument.configuration.appsettings.add | where-object {$_.key -eq "EncryptionKey"}).value
          
          
          #
          # Grab list of registered server
          #
          $URI=$API+"/infrastructure/servers/list"
          $aListServer=Invoke-RestMethod -Method Post -Uri $URI -Headers @{'X-ApiKey' = '********************'}
          
          if ($aListServer.Name -contains $SERVEUR){
          #
          # Mise à jour
          #
              $URI=$API+"/infrastructure/servers/update/"+$SERVEUR
              $body = @{
                  name="$SERVEUR";
                  hostname="$SERVEUR";
                  active=$true;
                  serverType="windows";
                  port="46336";
                  encryptionType="AES";
                  encryptionKey=$AESKey
              }
          
          }else{
          #
          # Creation
          #
              $URI=$API+"/infrastructure/servers/create/"+$SERVEUR
              $body = @{
                  name="$SERVEUR";
                  hostname="$SERVEUR";
                  serverType="windows";
                  active=$true;
                  drift="automaticallyRemediate";
                  port="46336";
                  roles=@("Baseline");
                  environments=@("Integration");
                  encryptionType="AES";
                  encryptionKey=$AESKey
              }
          }
          
          #
          # Appel de l'API
          #
          Invoke-RestMethod -Method Post -ContentType 'application/json;' -Uri $URI -Body (ConvertTo-Json $body) -Headers @{'X-ApiKey' = '********************'}
          #
          1 Reply Last reply Reply Quote 0

          Hello! It looks like you're interested in this conversation, but you don't have an account yet.

          Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

          With your input, this post could be even better 💗

          Register Login
          • 1 / 1
          • First post
            Last post
          Inedo Website Home • Support Home • Code of Conduct • Forums Guide • Documentation