Is there an API to get the host config zip?

I need to get on to the hosts and do some things after the host is created. Having to go into the UI and download the tar/zip is and automation killer…we’ll it at least complicates the automation design.

Is there an API or set of APIs that I can use to get the access keys for a given host?

Yes, everything the UI does is through the API. Generate an API key for the environment in the browser (User icon menu -> API & Keys), then save the access key, secret key, and endpoint URL somewhere.

(I will assume the endpoint is environment/project “1a5”, the default environment)

  • GET /v1/projects/1a5/hosts will list all the host resources
    • For all requests, send the access and secret key as the HTTP Basic auth username & password
    • e.g. curl -u 'accesskey:secretkey' 'http://your-rancher:8080/v1/projects/1a5/hosts' | jq .
  • Find the host you’re interested in in there; it will have a links map in the JSON, one of which is physicalHost
  • Follow that link to get the physicalHost resource, e.g. GET /v1/projects/1a5/hosts/1h1/physicalhost
  • The physicalHost resource will similarly have a config link if it was created through docker-machine.
  • GETting that link will give you the same tarball you download from the UI. From there you can untar it to get the id_rsa file to SSH to it.