|  | 
|  | 1 | +# Copyright 2021 Cloudera, Inc. | 
|  | 2 | +# | 
|  | 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); | 
|  | 4 | +# you may not use this file except in compliance with the License. | 
|  | 5 | +# You may obtain a copy of the License at | 
|  | 6 | +# | 
|  | 7 | +#      http://www.apache.org/licenses/LICENSE-2.0 | 
|  | 8 | +# | 
|  | 9 | +# Unless required by applicable law or agreed to in writing, software | 
|  | 10 | +# distributed under the License is distributed on an "AS IS" BASIS, | 
|  | 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
|  | 12 | +# See the License for the specific language governing permissions and | 
|  | 13 | +# limitations under the License. | 
|  | 14 | + | 
|  | 15 | +--- | 
|  | 16 | + | 
|  | 17 | +- name: Generate complete ecs cluster configs | 
|  | 18 | +  include_role: | 
|  | 19 | +    name: cloudera.cluster.config.cluster.ecs | 
|  | 20 | + | 
|  | 21 | +- name: Create databases and users | 
|  | 22 | +  include_role: | 
|  | 23 | +    name: cloudera.cluster.deployment.databases | 
|  | 24 | +  vars: | 
|  | 25 | +    services: "{{ cluster.ecs_databases | default(ecs_databases) }}" | 
|  | 26 | + | 
|  | 27 | +# Add PVC parcel repo - assume that this has been set via REMOTE_PARCEL_REPO_URLS in the cm config. We can add this in later if needed | 
|  | 28 | + | 
|  | 29 | +- name: Create ECS cluster | 
|  | 30 | +  cloudera.cluster.cm_api: | 
|  | 31 | +    endpoint: /clusters | 
|  | 32 | +    method: POST | 
|  | 33 | +    body: "{{ lookup('template', 'cluster_template/ecs/clusters.j2', convert_data=False) }}" | 
|  | 34 | +  register: cluster_creation_result | 
|  | 35 | +  failed_when: '"Status code was 400" in cluster_creation_result.msg' | 
|  | 36 | +  when: not cluster_template_dry_run | 
|  | 37 | + | 
|  | 38 | +- name: Add hosts to ECS cluster | 
|  | 39 | +  cloudera.cluster.cm_api: | 
|  | 40 | +    endpoint: /clusters/{{ cluster.name | urlencode() }}/hosts | 
|  | 41 | +    method: POST | 
|  | 42 | +    body: "{{ lookup('template', 'cluster_template/ecs/hosts.j2', convert_data=False) }}" | 
|  | 43 | +  register: cluster_hosts_result | 
|  | 44 | +  failed_when: '"Status code was 400" in cluster_hosts_result.msg' | 
|  | 45 | +  when: not cluster_template_dry_run | 
|  | 46 | + | 
|  | 47 | +- name: Add services to ECS cluster | 
|  | 48 | +  cloudera.cluster.cm_api: | 
|  | 49 | +    endpoint: /clusters/{{ cluster.name | urlencode() }}/services | 
|  | 50 | +    method: POST | 
|  | 51 | +    body: "{{ lookup('template', 'cluster_template/ecs/services.j2', convert_data=False) }}" | 
|  | 52 | +  register: cluster_services_result | 
|  | 53 | +  failed_when: '"Status code was 400" in cluster_services_result.msg' | 
|  | 54 | +  when: not cluster_template_dry_run | 
|  | 55 | + | 
|  | 56 | +- name: Get CM config | 
|  | 57 | +  cloudera.cluster.cm_api: | 
|  | 58 | +    endpoint: "cm/config" | 
|  | 59 | +    method: GET | 
|  | 60 | +  register: cm_config | 
|  | 61 | + | 
|  | 62 | +- set_fact: | 
|  | 63 | +    parcel_repos: "{{ (cm_config.json | json_query('items[?name==`REMOTE_PARCEL_REPO_URLS`].value') | default(['']))[0].split(',') | default([]) | union(cluster.repositories) }}" | 
|  | 64 | + | 
|  | 65 | +- name: Update parcelrepos | 
|  | 66 | +  cloudera.cluster.cm_api: | 
|  | 67 | +    endpoint: "cm/config" | 
|  | 68 | +    body: | 
|  | 69 | +      items: | 
|  | 70 | +        - name: REMOTE_PARCEL_REPO_URLS | 
|  | 71 | +          value: "{{ parcel_repos | join(', ') }}" | 
|  | 72 | +    method: PUT | 
|  | 73 | + | 
|  | 74 | +- name: Refresh parcel repos command | 
|  | 75 | +  cloudera.cluster.cm_api: | 
|  | 76 | +    endpoint: "/cm/commands/refreshParcelRepos" | 
|  | 77 | +    method: POST | 
|  | 78 | + | 
|  | 79 | +- set_fact: | 
|  | 80 | +    new_parcel_version: "{{ products | json_query('[?product==`ECS`].version') | first }}" | 
|  | 81 | + | 
|  | 82 | +- name: Start Parcel Download | 
|  | 83 | +  cloudera.cluster.cm_api: | 
|  | 84 | +    endpoint: "/clusters/{{cluster.name | urlencode() }}/parcels/products/ECS/versions/{{ new_parcel_version }}/commands/startDownload" | 
|  | 85 | +    method: POST | 
|  | 86 | + | 
|  | 87 | +- name: Wait for parcels to download | 
|  | 88 | +  cloudera.cluster.cm_api: | 
|  | 89 | +    endpoint: /clusters/{{cluster.name | urlencode() }}/parcels/products/ECS/versions/{{ new_parcel_version }} | 
|  | 90 | +  register: parcels_response | 
|  | 91 | +  until: parcels_response.json.stage in ("DOWNLOADED", "DISTRIBUTED", "ACTIVATED") | 
|  | 92 | +  retries: "{{ parcel_poll_max_retries | default(30) }}" | 
|  | 93 | +  delay: "{{ parcel_poll_duration | default(60) }}" | 
|  | 94 | + | 
|  | 95 | +- name: Start Parcel Distribution | 
|  | 96 | +  cloudera.cluster.cm_api: | 
|  | 97 | +    endpoint: "/clusters/{{cluster.name | urlencode() }}/parcels/products/ECS/versions/{{ new_parcel_version }}/commands/startDistribution" | 
|  | 98 | +    method: POST | 
|  | 99 | + | 
|  | 100 | +- name: Wait for parcels to become distributed to all hosts | 
|  | 101 | +  cloudera.cluster.cm_api: | 
|  | 102 | +    endpoint: /clusters/{{cluster.name | urlencode() }}/parcels/products/ECS/versions/{{ new_parcel_version }} | 
|  | 103 | +  register: parcels_response | 
|  | 104 | +  until:  parcels_response.json.stage in ("DISTRIBUTED", "ACTIVATED") | 
|  | 105 | +  retries: "{{ parcel_poll_max_retries | default(30) }}" | 
|  | 106 | +  delay: "{{ parcel_poll_duration | default(60) }}" | 
|  | 107 | + | 
|  | 108 | +- name: Activate Parcels | 
|  | 109 | +  cloudera.cluster.cm_api: | 
|  | 110 | +    endpoint: "/clusters/{{cluster.name | urlencode() }}/parcels/products/ECS/versions/{{ new_parcel_version }}/commands/activate" | 
|  | 111 | +    method: POST | 
|  | 112 | + | 
|  | 113 | +- name: Wait for parcels to become distributed to all hosts | 
|  | 114 | +  cloudera.cluster.cm_api: | 
|  | 115 | +    endpoint: /clusters/{{cluster.name | urlencode() }}/parcels/products/ECS/versions/{{ new_parcel_version }} | 
|  | 116 | +  register: parcels_response | 
|  | 117 | +  until:  parcels_response.json.stage in ("ACTIVATED") | 
|  | 118 | +  retries: "{{ parcel_poll_max_retries | default(30) }}" | 
|  | 119 | +  delay: "{{ parcel_poll_duration | default(60) }}" | 
|  | 120 | + | 
|  | 121 | +- name: Generate custom values | 
|  | 122 | +  set_fact: | 
|  | 123 | +    custom_values: "{{ lookup('template', 'cluster_template/ecs/controlPlaneValues.j2') | from_yaml | combine(cluster.controlplane_config, recursive=True) }}" | 
|  | 124 | + | 
|  | 125 | +- name: Show custom values | 
|  | 126 | +  debug: | 
|  | 127 | +    var: custom_values | 
|  | 128 | + | 
|  | 129 | +- name: Install ECS cluster | 
|  | 130 | +  cloudera.cluster.cm_api: | 
|  | 131 | +    endpoint: /controlPlanes/commands/installEmbeddedControlPlane | 
|  | 132 | +    method: POST | 
|  | 133 | +    body: | 
|  | 134 | +      remoteRepoUrl: "{{ cluster.pvc_repository }}" | 
|  | 135 | +      experienceClusterName: "{{ cluster.name }}" | 
|  | 136 | +      datalakeClusterName: "{{ cluster.datalake }}" | 
|  | 137 | +      valuesYaml: "{{ custom_values | to_yaml }}" | 
|  | 138 | +  register: controlplane_response | 
|  | 139 | + | 
0 commit comments