Created
June 5, 2017 20:32
-
-
Save superseb/807a32c8962f21fe887ea981b755e724 to your computer and use it in GitHub Desktop.
Rancher create k8s env template and environment with custom MTU using Ansible
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: localhost | |
connection: local | |
gather_facts: no | |
tasks: | |
- name: Create new environment template | |
uri: | |
url: "http://{{ ansible_ssh_host }}:8080/v2-beta/projecttemplate" | |
method: POST | |
body: '{"type":"projectTemplate","baseType":"projectTemplate","name":"k8s_mtu1400","state":"active","accountId":null,"created":"2017-06-05T20:11:45Z","createdTS":1496693505000,"data":{"fields":{"stacks":[{"name":"network-services","templateId":"library:infra*network-services"},{"name":"ipsec","templateId":"library:infra*ipsec"},{"name":"scheduler","templateId":"library:infra*scheduler"},{"name":"healthcheck","templateId":"library:infra*healthcheck"}]}},"description":null,"externalId":"catalog://library:project*cattle:0","isPublic":false,"kind":"projectTemplate","removeTime":null,"removed":null,"stacks":[{"type":"catalogTemplate","name":"healthcheck","templateId":"library:infra*healthcheck"},{"type":"catalogTemplate","name":"kubernetes","answers":{},"templateId":"library:infra*k8s"},{"type":"catalogTemplate","name":"network-services","templateId":"library:infra*network-services"},{"type":"catalogTemplate","name":"ipsec","templateVersionId":"library:infra*ipsec:7","answers":{"DOCKER_BRIDGE":"docker0","MTU":"1400","SUBNET":"10.42.0.0/16","RANCHER_DEBUG":false}},{"type":"catalogTemplate","name":"scheduler","templateId":"library:infra*scheduler"}],"transitioning":"no","transitioningMessage":null,"transitioningProgress":null,"uuid":null}' | |
status_code: 201 | |
body_format: json | |
register: environment_template_details | |
- name: Get id of k8s_mtu1400 environment template | |
uri: | |
url: "http://{{ ansible_ssh_host }}:8080/v2-beta/projecttemplates?name=k8s_mtu1400" | |
method: GET | |
status_code: 200 | |
register: environment_template_details | |
until: environment_template_details['json']['data'][0]['id'] is defined | |
retries: 30 | |
delay: 1 | |
- name: Store id of k8s_mtu1400 environment template as fact | |
set_fact: | |
environment_template_id: "{{ environment_template_details['json']['data'][0]['id'] }}" | |
- name: Create new environment | |
uri: | |
url: "http://{{ ansible_ssh_host }}:8080/v2-beta/projects" | |
method: POST | |
body: '{"description":"K8S MTU1400 environment", "name":"k8s_mtu1400_env", "projectTemplateId":"{{ environment_template_id }}"}' | |
status_code: 201 | |
body_format: json | |
register: environment_details | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment