Create a mesos environnement using APIs V1.2.0

in the process of a full automated deployment with several orchestrator.
For example, i’d like to automate creation of mesos and kubernetes environnement and automatically add new host using API as well.

any documentation somewhere that could help me achieving this ?

Thanks a lot for your help :slight_smile:

templateId=`curl http://rancher:8080/v2-beta/projecttemplates?name=mesos | jq -r '.data[0].id'`

curl -X POST \
  -H "Content-Type: application/json" \
  -d "{\"name\": \"My Mesos Project\", \"projectTemplateId\": \"${templateId}\"}" \
  http://rancher:8080/v2-beta/projects

thanks a lot @vincent !

definitely what i was looking for :slight_smile:

Hello,

first sorry to bring back such an old topic, but i didn’t find any solution and i’m banging my head against my desk now :frowning: - i’m playing with rancher 1.6.15 - no 2.0 yet

I’m trying to do something very similar. I need to extend the default “Cattle” template with services such as route53 & secrets. My understanding is that the most practical way would be to add a custom template with said services enabled and then use the exact same call in the sample above. Just like what i currently do manually when provisionning a new environment.

I’ve been trying to follow what the UI does when creating a template, but so far all i manage to create is an empty template with nothing in it.

What i’m trying to do (using ansible):

  • find the default Cattle template by hitting /v2-beta/projecttemplates?name=Cattle
  • extract the list of stacks defined in the result: (__rancher_init_cattle_template.json.data[0].stacks)
  • retrieve informations about the ‘secrets’ and ‘route53’ stacks (such as GET /v1-catalog/templates/library:infra*route53), pick the defaultVersion url and hit it : (GET __rancher_init_route53_versions.json.versionLinks[__rancher_init_route53_version])
  • define 2 “stack documents” that i concatenate to the list of stacks in a new json document matching a projectTemplate object:
      type: catalogTemplate
      templateId: "library:infra*route53"
      answers:
        AWS_ACCESS_KEY: ""
        AWS_SECRET_KEY: ""
        TTL: 60
        ROOT_DOMAIN: "{{ environment }}.{{top_level_domain}}"
        ROUTE53_ZONE_ID: ""
        NAME_TEMPLATE: '%\{\{service_name\}\}.%\{\{stack_name\}\}.%\{\{environment_name\}\}'
        HEALTH_CHECK: 10000
        ROUTE53_MAX_RETRIES: 3
    - name: secrets
      templateId: library:infra*secrets
      type: catalogTemplate
  • Use all this data to populate a json doc extracted from what the UI does (using developer tools), and POST /v2-beta/projectemplates

The result is that i get a new template defined but it is totally empty, doesn’t have name nor title and all i can do with it is delete it… i must be missing something, but if you would have a similar example that creates a workable projectTemplate, that would be awesome…