diff --git a/ansible/es.yml b/ansible/es.yml index 8042e5dbfa5db1306cbd0299b8cc3cb8db292a0e..c526414f47c0d87a5efbb7956ce26d21d2d62f36 100644 --- a/ansible/es.yml +++ b/ansible/es.yml @@ -6,10 +6,16 @@ - es_snapshot_host: "{{app_es_snapshot_host}}" - snapshot_base_path: "{{app_snapshot_base_path}}" roles: - - es-azure-snapshot - - es5-snapshot-purge + - role: es-azure-snapshot + when: cloud_service_provider == "azure" + - role: es-s3-snapshot + when: cloud_service_provider == "aws" + - role: es-gcs-snapshot + when: cloud_service_provider == "gcloud" + - role: es5-snapshot-purge tags: - es_backup + run_once: true - hosts: log-es-backup become: yes @@ -19,16 +25,13 @@ - es_snapshot_host: "{{log_es_snapshot_host}}" - snapshot_base_path: "{{log_snapshot_base_path}}" roles: - - es-azure-snapshot + - role: es-azure-snapshot + when: cloud_service_provider == "azure" + - role: es-s3-snapshot + when: cloud_service_provider == "aws" + - role: es-gcs-snapshot + when: cloud_service_provider == "gcloud" - es5-snapshot-purge tags: - log_es_backup - -# - hosts: log-es -# become: yes -# vars_files: -# - ['{{inventory_dir}}/secrets.yml', 'secrets/{{env}}.yml'] -# roles: -# - es2-data-purge -# tags: -# - purge_old_logs + run_once: true \ No newline at end of file diff --git a/ansible/inventory/env/group_vars/all.yml b/ansible/inventory/env/group_vars/all.yml index 5e186674e16dc7e023e9ce3af586c9bf198baee8..1f7bc114303ec1589ebda9e1a862eca60d0d68cc 100644 --- a/ansible/inventory/env/group_vars/all.yml +++ b/ansible/inventory/env/group_vars/all.yml @@ -132,6 +132,8 @@ cassandra_rpc_address: 0.0.0.0 cassandra_restore_dir: "/home/{{ ansible_ssh_user }}/" cassandra_backup_azure_container_name: cassandra-backup cassandra_backup_dir: /data/cassandra/backup +### Release 5.0.0 ### +cassandra_isMutiDCEnabled: false keycloak_realm: sunbird sunbird_content_player_url: "http://kong:8000/" diff --git a/ansible/provision-log-es.yml b/ansible/provision-log-es.yml index 0959dd349c0c2aa5efe0a26be5c66323747819fc..51262b685a29586cfe8d558f51c374c9c89236ba 100644 --- a/ansible/provision-log-es.yml +++ b/ansible/provision-log-es.yml @@ -1,13 +1,10 @@ - hosts: log-es become: yes vars: - es_version: "6.8.10" + es_version: "6.8.22" es_etc_discovery_zen_ping_unicast_hosts: "{{ groups['log-es'] }}" es_etc_cluster_name: "{{ node_name }}" es_heap_size: "{{ log_es_heap_size | default('1g') }}" - es_plugins_reinstall: true - es_plugins: - - plugin: "repository-azure" es_config: cluster.name: "{{ log_es_etc_cluster_name }}" discovery.zen.ping.unicast.hosts: "{{ groups['log-es'] }}" @@ -49,5 +46,7 @@ method: PUT return_content: true timeout: 30 - retries: 3 - delay: 10 + register: _result + until: _result.status == 200 + retries: 3 + delay: 10 \ No newline at end of file diff --git a/ansible/roles/elasticsearch_dependencies/main.yml b/ansible/roles/elasticsearch_dependencies/tasks/main.yml similarity index 63% rename from ansible/roles/elasticsearch_dependencies/main.yml rename to ansible/roles/elasticsearch_dependencies/tasks/main.yml index b4752a62af76d2f4637c5fb3147a8bc422be002e..20c7bf0c82eb625ce612953f3d9a38eaa4035efe 100644 --- a/ansible/roles/elasticsearch_dependencies/main.yml +++ b/ansible/roles/elasticsearch_dependencies/tasks/main.yml @@ -2,5 +2,5 @@ - debug: msg="Installing jmespath" - name: Install jmespath - apt: name=jmespath state=present + apt: name=python3-jmespath state=present become: yes diff --git a/ansible/roles/es-azure-restore/tasks/main.yml b/ansible/roles/es-azure-restore/tasks/main.yml index f45a97587b2a857fa5971593a180a34791adec35..ff71c19a11c934c5e88f21a0a1825d8acdc625f1 100644 --- a/ansible/roles/es-azure-restore/tasks/main.yml +++ b/ansible/roles/es-azure-restore/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: Set azure snapshot for the first time uri: - url: "http://{{ es_restore_host }}:9200/_snapshot/azurebackup" + url: "http://{{ es_restore_host }}:9200/_snapshot/{{ snapshot_base_path }}" method: PUT body: "{{ snapshot_create_request_body | to_json }}" headers: @@ -9,12 +9,12 @@ - name: Restore ES from Azure backup uri: - url: "http://{{ es_restore_host }}:9200/_snapshot/azurebackup/{{snapshot_number}}/_restore" + url: "http://{{ es_restore_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}/_restore" method: POST - name: "Wait for restore to be completed" uri: - url: "http://{{ es_restore_host }}:9200/_snapshot/azurebackup/{{snapshot_number}}/_status" + url: "http://{{ es_restore_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}/_status" method: GET return_content: yes status_code: 200 diff --git a/ansible/roles/es-azure-snapshot/defaults/main.yml b/ansible/roles/es-azure-snapshot/defaults/main.yml index 36295b9f9fbf3974de5b5b8ce8f9480f803ba1d1..99787b0f89be78d05d6fed7f57e31f656d1524fa 100644 --- a/ansible/roles/es-azure-snapshot/defaults/main.yml +++ b/ansible/roles/es-azure-snapshot/defaults/main.yml @@ -1,11 +1,13 @@ snapshot_create_request_body: { type: azure, settings: { - container: "elasticsearch-snapshots", + container: "{{ es_azure_backup_folder_name }}", base_path: "{{ snapshot_base_path }}_{{ base_path_date }}" } } # Override these values -es_snapshot_host: localhost -snapshot_base_path: default +es_snapshot_host: "localhost" +snapshot_base_path: "default" + +es_azure_backup_folder_name: "elasticsearch-snapshots" \ No newline at end of file diff --git a/ansible/roles/es-azure-snapshot/tasks/main.yml b/ansible/roles/es-azure-snapshot/tasks/main.yml index d9e01c55293a7debdeaf6dfa822168fff87a1671..d2880013d51239dd91ef76da027744ef0b49c71f 100644 --- a/ansible/roles/es-azure-snapshot/tasks/main.yml +++ b/ansible/roles/es-azure-snapshot/tasks/main.yml @@ -2,41 +2,42 @@ - set_fact: base_path_date="{{ lookup('pipe','date +%Y-%m') }}" -- name: Create azure snapshot +- set_fact: snapshot_number="snapshot_{{ lookup('pipe','date +%s') }}" + +- name: Ensure backup folder exists in azure blob + shell: "az storage container create --name {{ es_azure_backup_folder_name }}" + environment: + AZURE_STORAGE_ACCOUNT: "{{ azure_management_storage_account_name }}" + AZURE_STORAGE_KEY: "{{ azure_management_storage_account_key }}" + +- name: Create Azure Repository uri: - url: "http://{{ es_snapshot_host }}:9200/_snapshot/azurebackup" + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}" method: PUT body: "{{ snapshot_create_request_body | to_json }}" headers: Content-Type: "application/json" -- debug: - var: "{{ snapshot_base_path }}" - -- set_fact: snapshot_number="snapshot_{{ansible_date_time.epoch}}" - - name: Take new snapshot uri: - url: "http://{{ es_snapshot_host }}:9200/_snapshot/azurebackup/{{snapshot_number}}" + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}" method: PUT - body: > - {"indices":"*","include_global_state":false} headers: Content-Type: "application/json" - name: Print all snapshots uri: - url: "http://{{ es_snapshot_host }}:9200/_snapshot/azurebackup/_all" + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/_all" method: GET - name: Print status of current snapshot uri: - url: "http://{{ es_snapshot_host }}:9200/_snapshot/azurebackup/{{snapshot_number}}" + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}" method: GET - name: "Wait for backup to be completed" uri: - url: "http://{{ es_snapshot_host }}:9200/_snapshot/azurebackup/{{snapshot_number}}" + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}" method: GET return_content: yes status_code: 200 diff --git a/ansible/roles/es-curator/defaults/main.yml b/ansible/roles/es-curator/defaults/main.yml index a4728a5b39b1f650b175cb78d31f5894e568789c..9fd4efe2c8571c7ef87e290fe6e54b9313c46981 100644 --- a/ansible/roles/es-curator/defaults/main.yml +++ b/ansible/roles/es-curator/defaults/main.yml @@ -1,6 +1,2 @@ -# es_curator_major_version: 3 -# es_curator_version: 3.4.1-1 - es_curator_major_version: 5 -es_curator_version: 5.7.6 -python_es_curator_version: 3.4.1-1 +es_curator_version: 5.8.4 \ No newline at end of file diff --git a/ansible/roles/es-curator/tasks/main.yml b/ansible/roles/es-curator/tasks/main.yml index 689b87be46d3a0985dea2ed5eb75ab12295e58f7..c4a8bacee7a3cdc0a018845e700a2f9f1178b743 100644 --- a/ansible/roles/es-curator/tasks/main.yml +++ b/ansible/roles/es-curator/tasks/main.yml @@ -7,11 +7,6 @@ - debug: msg: "{{ es_curator_version }}" -- name: Install python elasticsearch curator - apt: - name: python-elasticsearch-curator={{ python_es_curator_version }} - force: yes - - name: Install elasticsearch curator apt: name: elasticsearch-curator={{ es_curator_version }} diff --git a/ansible/roles/es-gcs-snapshot/defaults/main.yml b/ansible/roles/es-gcs-snapshot/defaults/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..3c2efa9a7f8b5496ea70b720b35ad48192e64439 --- /dev/null +++ b/ansible/roles/es-gcs-snapshot/defaults/main.yml @@ -0,0 +1,12 @@ +snapshot_create_request_body: { + type: gcs, + settings: { + bucket: "{{ gcs_management_bucket_name }}", + base_path: "{{ es_gcs_backup_folder_name }}/{{ snapshot_base_path }}_{{ base_path_date }}" + } +} + +# Override these values +es_snapshot_host: "localhost" +snapshot_base_path: "default" +es_gcs_backup_folder_name: "elasticsearch-snapshots" \ No newline at end of file diff --git a/ansible/roles/es-gcs-snapshot/tasks/main.yml b/ansible/roles/es-gcs-snapshot/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..55f50b17ad4d1f60013277d490255f2dcfee8a19 --- /dev/null +++ b/ansible/roles/es-gcs-snapshot/tasks/main.yml @@ -0,0 +1,42 @@ +--- + +- set_fact: base_path_date="{{ lookup('pipe','date +%Y-%m') }}" + +- set_fact: snapshot_number="snapshot_{{ lookup('pipe','date +%s') }}" + +- name: Create GCS Repository + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}" + method: PUT + body: "{{ snapshot_create_request_body | to_json }}" + headers: + Content-Type: "application/json" + +- name: Take new snapshot + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}" + method: PUT + headers: + Content-Type: "application/json" + +- name: Print all snapshots + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/_all" + method: GET + +- name: Print status of current snapshot + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}" + method: GET + +- name: "Wait for backup to be completed" + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}" + method: GET + return_content: yes + status_code: 200 + body_format: json + register: result + until: result.json.snapshots[0].state == 'SUCCESS' + retries: 120 + delay: 10 diff --git a/ansible/roles/es-s3-snapshot/defaults/main.yml b/ansible/roles/es-s3-snapshot/defaults/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..2ca18929b470f370f13cda93381570cbbfe612e7 --- /dev/null +++ b/ansible/roles/es-s3-snapshot/defaults/main.yml @@ -0,0 +1,12 @@ +snapshot_create_request_body: { + type: s3, + settings: { + bucket: "{{ aws_management_bucket_name }}", + base_path: "{{ es_s3_backup_folder_name }}/{{ snapshot_base_path }}_{{ base_path_date }}" + } +} + +# Override these values +es_snapshot_host: "localhost" +snapshot_base_path: "default" +es_s3_backup_folder_name: "elasticsearch-snapshots" \ No newline at end of file diff --git a/ansible/roles/es-s3-snapshot/tasks/main.yml b/ansible/roles/es-s3-snapshot/tasks/main.yml new file mode 100644 index 0000000000000000000000000000000000000000..aee768626c0b2eaa16f01d327251722fdac92ca3 --- /dev/null +++ b/ansible/roles/es-s3-snapshot/tasks/main.yml @@ -0,0 +1,42 @@ +--- + +- set_fact: base_path_date="{{ lookup('pipe','date +%Y-%m') }}" + +- set_fact: snapshot_number="snapshot_{{ lookup('pipe','date +%s') }}" + +- name: Create S3 Repository + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}" + method: PUT + body: "{{ snapshot_create_request_body | to_json }}" + headers: + Content-Type: "application/json" + +- name: Take new snapshot + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}" + method: PUT + headers: + Content-Type: "application/json" + +- name: Print all snapshots + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/_all" + method: GET + +- name: Print status of current snapshot + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}" + method: GET + +- name: "Wait for backup to be completed" + uri: + url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{ snapshot_number }}" + method: GET + return_content: yes + status_code: 200 + body_format: json + register: result + until: result.json.snapshots[0].state == 'SUCCESS' + retries: 120 + delay: 10 diff --git a/ansible/roles/es2-snapshot-purge/defaults/main.yml b/ansible/roles/es2-snapshot-purge/defaults/main.yml index 4f64ac4aff660a022ba7baeaab77a383a2549b11..0a619ae4b008dd40d62192e4eb50ea05ad587332 100644 --- a/ansible/roles/es2-snapshot-purge/defaults/main.yml +++ b/ansible/roles/es2-snapshot-purge/defaults/main.yml @@ -1,2 +1,2 @@ es_snapshot_retention_days: 30 -es_snapshot_repository: azurebackup +es_snapshot_repository: "{{ snapshot_base_path }}" diff --git a/ansible/roles/es5-snapshot-purge/defaults/main.yml b/ansible/roles/es5-snapshot-purge/defaults/main.yml index 739d0bf3112e3e4c9f50f9931f19b016b8e5c3ad..cab1182a3dfa493927e420d996ed4a61408c8932 100644 --- a/ansible/roles/es5-snapshot-purge/defaults/main.yml +++ b/ansible/roles/es5-snapshot-purge/defaults/main.yml @@ -1,5 +1,5 @@ es_snapshot_host: localhost -es_snapshot_repository: azurebackup +es_snapshot_repository: "{{ snapshot_base_path }}" es_snapshot_retention_days: 30 es_curator_config_dir: /etc/curator es_curator_config_file: "{{ es_curator_config_dir }}/curator.yml" diff --git a/ansible/roles/es5-snapshot-purge/meta/main.yml b/ansible/roles/es5-snapshot-purge/meta/main.yml index e26db1f14555acf283684466064addb2f7a399f1..8b4e268b5d2de70f0f4b3838efcff2bd13442deb 100644 --- a/ansible/roles/es5-snapshot-purge/meta/main.yml +++ b/ansible/roles/es5-snapshot-purge/meta/main.yml @@ -1,3 +1,3 @@ --- dependencies: - - { role: es-curator, es_curator_major_version: 5, es_curator_version: 5.8.1, python_es_curator_version: 3.4.1-1 } + - { role: es-curator, es_curator_major_version: 5, es_curator_version: 5.8.4 } diff --git a/ansible/roles/es6/defaults/main.yml b/ansible/roles/es6/defaults/main.yml index b2402c73a287b60b7cc5f66e4f52b02000b5ea43..c0063fcc909326e2bc10cfa6119bfd8d03d3893f 100644 --- a/ansible/roles/es6/defaults/main.yml +++ b/ansible/roles/es6/defaults/main.yml @@ -1,6 +1,6 @@ --- es_major_version: "6.x" -es_version: "6.2.3" +es_version: "6.8.22" es_version_lock: false es_use_repository: true es_templates_fileglob: "files/templates/*.json" @@ -11,7 +11,6 @@ es_start_service: true es_java_install: true update_java: false es_restart_on_change: true -es_plugins_reinstall: false es_scripts: false es_templates: true es_user: elasticsearch @@ -22,7 +21,7 @@ es_pid_dir: "/var/run/elasticsearch" es_data_dirs: "/var/lib/elasticsearch" es_log_dir: "/var/log/elasticsearch" es_max_open_files: 65536 -es_max_threads: "{{ 2048 if ( es_version | version_compare('6.0.0', '<')) else 8192 }}" +es_max_threads: "{{ 2048 if ( es_version is version('6.0.0', '<')) else 8192 }}" es_max_map_count: 262144 es_allow_downgrades: false es_enable_xpack: false @@ -41,4 +40,9 @@ conf_dir: '' data_dirs: '' # JVM custom parameters es_jvm_custom_parameters: '' -es_heap_size: "2g" +es_heap_size: "1g" +es_plugins_reinstall: true +es_plugins: +- plugin: "repository-azure" +- plugin: "repository-s3" +- plugin: "repository-gcs" \ No newline at end of file diff --git a/ansible/roles/es6/tasks/azure-plugin.yml b/ansible/roles/es6/tasks/azure-plugin.yml deleted file mode 100644 index 46d3079babcde748ebecc55f0d1d7fa7a4488454..0000000000000000000000000000000000000000 --- a/ansible/roles/es6/tasks/azure-plugin.yml +++ /dev/null @@ -1,11 +0,0 @@ -- name: Check if plugin already installed or not - shell: "curl -s localhost:9200/_cat/plugins | awk '{print $2}' |head -1" - register: plugin_output - -- name: check the output - debug: - var: plugin_output - -- name: Install plugin - shell: ES_PATH_CONF=/etc/elasticsearch/"{{ es_instance_name }}" /usr/share/elasticsearch/bin/elasticsearch-plugin install repository-azure - when: plugin_output.stdout != "repository-azure" diff --git a/ansible/roles/es6/tasks/elasticsearch-parameters.yml b/ansible/roles/es6/tasks/elasticsearch-parameters.yml index 13c6472a3d35a26d9989de12905c656dc8e23088..a9cc13830a60c1226ab0e4a6c2bbbac66d819e2f 100644 --- a/ansible/roles/es6/tasks/elasticsearch-parameters.yml +++ b/ansible/roles/es6/tasks/elasticsearch-parameters.yml @@ -58,7 +58,7 @@ #Relies on elasticsearch distribution installing a serviced script to determine whether one should be copied. - name: set fact use_system_d - set_fact: use_system_d={{(ansible_distribution == 'Debian' and ansible_distribution_version | version_compare('8', '>=')) or (ansible_distribution in ['RedHat','CentOS'] and ansible_distribution_version | version_compare('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version | version_compare('15', '>=')) }} + set_fact: use_system_d={{(ansible_distribution == 'Debian' and ansible_distribution_version is version('8', '>=')) or (ansible_distribution in ['RedHat','CentOS'] and ansible_distribution_version is version('7', '>=')) or (ansible_distribution == 'Ubuntu' and ansible_distribution_version is version('15', '>=')) }} - name: set fact instance_sysd_script set_fact: instance_sysd_script={{sysd_script | dirname }}/{{es_instance_name}}_{{sysd_script | basename}} diff --git a/ansible/roles/es6/tasks/main.yml b/ansible/roles/es6/tasks/main.yml index 7bf1a214a9617875c6cab186dbef4d500139c3d1..1de1eeff8e222a52f5e0c9ea9fd2ce3cbdf14369 100644 --- a/ansible/roles/es6/tasks/main.yml +++ b/ansible/roles/es6/tasks/main.yml @@ -31,16 +31,27 @@ tags: - plugins -# Install Elasticsearch plugin for backups -- name: include elasticsearch plugin install - include: azure-plugin.yml - #We always execute xpack as we may need to remove features - name: include xpack/elasticsearch-xpack.yml include: xpack/elasticsearch-xpack.yml tags: - xpack +- name: include plugins/create-keystore.yml + include: plugins/create-keystore.yml + +- name: include plugins/repository-azure.yml + include: plugins/repository-azure.yml + when: cloud_service_provider == "azure" + +- name: include plugins/repository-s3.yml + include: plugins/repository-s3.yml + when: cloud_service_provider == "aws" + +- name: include plugins/repository-gcs.yml + include: plugins/repository-gcs.yml + when: cloud_service_provider == "gcloud" + - name: flush handlers meta: flush_handlers @@ -79,15 +90,3 @@ when: es_templates tags: - templates - -# Add ES Plugin credentials for backups -- name: Add ES Backup variables to elasticsearch to have backups enabled - lineinfile: - path: '{{conf_dir}}/elasticsearch.yml' - line: 'cloud.azure.storage.default.{{item.key}}: {{item.value}}' - regexp: "cloud.azure.storage.default.{{ item.key }}.*" - with_items: - - {key: 'account', value: '{{ sunbird_management_storage_account_name }}'} - - {key: 'key', value: '{{ sunbird_management_storage_account_key }}'} - when: sunbird_management_storage_account_name is defined and sunbird_management_storage_account_key is defined - notify: restart elasticsearch diff --git a/ansible/roles/es6/tasks/plugins/create-keystore.yml b/ansible/roles/es6/tasks/plugins/create-keystore.yml new file mode 100644 index 0000000000000000000000000000000000000000..656183902d6a72594995f02c31c1be54e147e0eb --- /dev/null +++ b/ansible/roles/es6/tasks/plugins/create-keystore.yml @@ -0,0 +1,13 @@ +--- +- name: Check if elasticsearch keystore exists or not + become: yes + stat: + path: "{{ conf_dir }}/elasticsearch.keystore" + register: elasticsearch_keystore_file + +- name: Create the elasticsearch keystore if not exists + become: yes + command: "{{es_home}}/bin/elasticsearch-keystore create" + environment: + ES_PATH_CONF: "{{ conf_dir }}" + when: elasticsearch_keystore_file.stat.exists == false diff --git a/ansible/roles/es6/tasks/plugins/repository-azure.yml b/ansible/roles/es6/tasks/plugins/repository-azure.yml new file mode 100644 index 0000000000000000000000000000000000000000..170a84000eb4d55d5090d58e2ede8a077c857684 --- /dev/null +++ b/ansible/roles/es6/tasks/plugins/repository-azure.yml @@ -0,0 +1,15 @@ +--- +- name: Add default azure account name for backups + become: yes + shell: echo "{{ azure_management_storage_account_name }}" | {{ es_home }}/bin/elasticsearch-keystore add -f azure.client.default.account + no_log: True + environment: + ES_PATH_CONF: "{{ conf_dir }}" + + +- name: Add default azure account key for backups + become: yes + shell: echo "{{ azure_management_storage_account_key }}" | {{ es_home }}/bin/elasticsearch-keystore add -f azure.client.default.key + no_log: True + environment: + ES_PATH_CONF: "{{ conf_dir }}" \ No newline at end of file diff --git a/ansible/roles/es6/tasks/plugins/repository-gcs.yml b/ansible/roles/es6/tasks/plugins/repository-gcs.yml new file mode 100644 index 0000000000000000000000000000000000000000..7d5c32e52ee6a22bb996b9c453c6046a2d10a644 --- /dev/null +++ b/ansible/roles/es6/tasks/plugins/repository-gcs.yml @@ -0,0 +1,18 @@ +--- +- name: Create the gcs service account file from variable + become: yes + copy: + dest: "{{ conf_dir }}/gcs_management_bucket_service_account.json" + content: "{{ gcs_management_bucket_service_account }}" + +- name: Add gcs service account file to keystore + become: yes + shell: "{{ es_home }}/bin/elasticsearch-keystore add-file -f gcs.client.default.credentials_file {{ conf_dir }}/gcs_management_bucket_service_account.json" + no_log: True + environment: + ES_PATH_CONF: "{{ conf_dir }}" + +- name: Remove the service account file + file: + path: "{{ conf_dir }}/gcs_management_bucket_service_account.json" + state: absent \ No newline at end of file diff --git a/ansible/roles/es6/tasks/plugins/repository-s3.yml b/ansible/roles/es6/tasks/plugins/repository-s3.yml new file mode 100644 index 0000000000000000000000000000000000000000..b5897792abc272dd1cdeddfdcfac95479ec59cfb --- /dev/null +++ b/ansible/roles/es6/tasks/plugins/repository-s3.yml @@ -0,0 +1,14 @@ +--- +- name: Add default aws account name for backups + become: yes + shell: echo "{{ aws_management_bucket_user_access_key }}" | {{ es_home }}/bin/elasticsearch-keystore add -f s3.client.default.access_key + no_log: True + environment: + ES_PATH_CONF: "{{ conf_dir }}" + +- name: Add default aws account key for backups + become: yes + shell: echo "{{ aws_management_bucket_user_secret_key }}" | {{ es_home }}/bin/elasticsearch-keystore add -f s3.client.default.secret_key + no_log: True + environment: + ES_PATH_CONF: "{{ conf_dir }}" diff --git a/ansible/roles/es6/tasks/xpack/elasticsearch-xpack.yml b/ansible/roles/es6/tasks/xpack/elasticsearch-xpack.yml index ec82a68a6f51114e15df5a26ac75a6841c384692..4fe1cab279dfe002af9fd0428143d490cad4630c 100644 --- a/ansible/roles/es6/tasks/xpack/elasticsearch-xpack.yml +++ b/ansible/roles/es6/tasks/xpack/elasticsearch-xpack.yml @@ -19,4 +19,4 @@ - name: Set elasticsearch.keystore Permissions become: yes file: state=file path={{ conf_dir }}/elasticsearch.keystore owner={{ es_user }} group={{ es_group }} - when: es_enable_xpack and "security" in es_xpack_features and (es_version | version_compare('6.0.0', '>')) + when: es_enable_xpack and "security" in es_xpack_features and (es_version is version('6.0.0', '>')) diff --git a/ansible/roles/es6/tasks/xpack/security/elasticsearch-security.yml b/ansible/roles/es6/tasks/xpack/security/elasticsearch-security.yml index 14f4d203868de8117f4dcaebf4ea8f1e46dfcbec..9d5d4dc814d6866c8c53d448801a3b72733a388f 100644 --- a/ansible/roles/es6/tasks/xpack/security/elasticsearch-security.yml +++ b/ansible/roles/es6/tasks/xpack/security/elasticsearch-security.yml @@ -20,12 +20,12 @@ environment: ES_PATH_CONF: "{{ conf_dir }}" when: - - (es_enable_xpack and "security" in es_xpack_features) and (es_version | version_compare('6.0.0', '>')) + - (es_enable_xpack and "security" in es_xpack_features) and (es_version is version('6.0.0', '>')) - name: Create Bootstrap password for elastic user shell: echo "{{es_api_basic_auth_password}}" | {{es_home}}/bin/elasticsearch-keystore add -x 'bootstrap.password' when: - - (es_enable_xpack and "security" in es_xpack_features) and (es_version | version_compare('6.0.0', '>')) and es_api_basic_auth_username is defined and list_keystore is defined and es_api_basic_auth_username == 'elastic' and 'bootstrap.password' not in list_keystore.stdout_lines + - (es_enable_xpack and "security" in es_xpack_features) and (es_version is version('6.0.0', '>')) and es_api_basic_auth_username is defined and list_keystore is defined and es_api_basic_auth_username == 'elastic' and 'bootstrap.password' not in list_keystore.stdout_lines environment: ES_PATH_CONF: "{{ conf_dir }}" no_log: true diff --git a/ansible/roles/es6/templates/elasticsearch.yml.j2 b/ansible/roles/es6/templates/elasticsearch.yml.j2 index 030cc6e1a506d59f75478c7c9a3bf8a0782c01a1..d6aaab45c9dc380590ff650dbdb71e9a47b2e7bb 100644 --- a/ansible/roles/es6/templates/elasticsearch.yml.j2 +++ b/ansible/roles/es6/templates/elasticsearch.yml.j2 @@ -21,7 +21,7 @@ node.name: {{inventory_hostname}}-{{es_instance_name}} # Path to directory containing configuration (this file and logging.yml): -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} path.conf: {{ conf_dir }} {% endif %} diff --git a/ansible/roles/es6/templates/init/debian/elasticsearch.j2 b/ansible/roles/es6/templates/init/debian/elasticsearch.j2 index efe2c37f6c40f7941475b3f66ae180a5638b6352..22af436d6b9dc32e5021a161bc2f21042f1feb9f 100755 --- a/ansible/roles/es6/templates/init/debian/elasticsearch.j2 +++ b/ansible/roles/es6/templates/init/debian/elasticsearch.j2 @@ -92,7 +92,7 @@ fi # Define other required variables PID_FILE="$PID_DIR/$NAME.pid" DAEMON=$ES_HOME/bin/elasticsearch -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} DAEMON_OPTS="-d -p $PID_FILE -Edefault.path.logs=$LOG_DIR -Edefault.path.data=$DATA_DIR -Edefault.path.conf=$CONF_DIR" {% else %} DAEMON_OPTS="-d -p $PID_FILE" diff --git a/ansible/roles/es6/templates/init/redhat/elasticsearch.j2 b/ansible/roles/es6/templates/init/redhat/elasticsearch.j2 index c993e14365e897ffb8dff4ffde76a64015485726..d32e393b2fdde8b363f8921c8f95ea9b8e42c85e 100755 --- a/ansible/roles/es6/templates/init/redhat/elasticsearch.j2 +++ b/ansible/roles/es6/templates/init/redhat/elasticsearch.j2 @@ -140,7 +140,7 @@ start() { cd $ES_HOME echo -n $"Starting $prog: " # if not running, start it up here, usually something like "daemon $exec" -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d -Edefault.path.logs=$LOG_DIR -Edefault.path.data=$DATA_DIR -Edefault.path.conf=$CONF_DIR {% else %} daemon --user $ES_USER --pidfile $pidfile $exec -p $pidfile -d diff --git a/ansible/roles/es6/templates/log4j2.properties.j2 b/ansible/roles/es6/templates/log4j2.properties.j2 index 269be5290bf3ed457a4b6690caa5803d5b1dcfab..330f1435b8b573ec15c5153c049ff2d1b2b13b36 100644 --- a/ansible/roles/es6/templates/log4j2.properties.j2 +++ b/ansible/roles/es6/templates/log4j2.properties.j2 @@ -11,14 +11,14 @@ appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n appender.rolling.type = RollingFile appender.rolling.name = rolling -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} appender.rolling.fileName = ${sys:es.logs}.log {% else %} appender.rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}.log {% endif %} appender.rolling.layout.type = PatternLayout appender.rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} appender.rolling.filePattern = ${sys:es.logs}-%d{yyyy-MM-dd}.log {% else %} appender.rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}-%d{yyyy-MM-dd}-%i.log.gz @@ -27,7 +27,7 @@ appender.rolling.policies.type = Policies appender.rolling.policies.time.type = TimeBasedTriggeringPolicy appender.rolling.policies.time.interval = 1 appender.rolling.policies.time.modulate = true -{% if (es_version | version_compare('6.0.0', '>')) %} +{% if (es_version is version('6.0.0', '>')) %} appender.rolling.policies.size.type = SizeBasedTriggeringPolicy appender.rolling.policies.size.size = 128MB appender.rolling.strategy.type = DefaultRolloverStrategy @@ -45,14 +45,14 @@ rootLogger.appenderRef.rolling.ref = rolling appender.deprecation_rolling.type = RollingFile appender.deprecation_rolling.name = deprecation_rolling -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} appender.deprecation_rolling.fileName = ${sys:es.logs}_deprecation.log {% else %} appender.deprecation_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation.log {% endif %} appender.deprecation_rolling.layout.type = PatternLayout appender.deprecation_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%.-10000m%n -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} appender.deprecation_rolling.filePattern = ${sys:es.logs}_deprecation-%i.log.gz {% else %} appender.deprecation_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_deprecation-%i.log.gz @@ -70,14 +70,14 @@ logger.deprecation.additivity = false appender.index_search_slowlog_rolling.type = RollingFile appender.index_search_slowlog_rolling.name = index_search_slowlog_rolling -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} appender.index_search_slowlog_rolling.fileName = ${sys:es.logs}_index_search_slowlog.log {% else %} appender.index_search_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog.log {% endif %} appender.index_search_slowlog_rolling.layout.type = PatternLayout appender.index_search_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs}_index_search_slowlog-%d{yyyy-MM-dd}.log {% else %} appender.index_search_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_search_slowlog-%d{yyyy-MM-dd}.log @@ -94,14 +94,14 @@ logger.index_search_slowlog_rolling.additivity = false appender.index_indexing_slowlog_rolling.type = RollingFile appender.index_indexing_slowlog_rolling.name = index_indexing_slowlog_rolling -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs}_index_indexing_slowlog.log {% else %} appender.index_indexing_slowlog_rolling.fileName = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog.log {% endif %} appender.index_indexing_slowlog_rolling.layout.type = PatternLayout appender.index_indexing_slowlog_rolling.layout.pattern = [%d{ISO8601}][%-5p][%-25c] %marker%.-10000m%n -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs}_index_indexing_slowlog-%d{yyyy-MM-dd}.log {% else %} appender.index_indexing_slowlog_rolling.filePattern = ${sys:es.logs.base_path}${sys:file.separator}${sys:es.logs.cluster_name}_index_indexing_slowlog-%d{yyyy-MM-dd}.log diff --git a/ansible/roles/es6/templates/systemd/elasticsearch.j2 b/ansible/roles/es6/templates/systemd/elasticsearch.j2 index 1c32b1f5a38298590a90ead3aa6e566ea0ca6919..b4ef89753899c554b997f90fb3c6bf5240e6e1a3 100644 --- a/ansible/roles/es6/templates/systemd/elasticsearch.j2 +++ b/ansible/roles/es6/templates/systemd/elasticsearch.j2 @@ -19,13 +19,13 @@ WorkingDirectory={{es_home}} User={{es_user}} Group={{es_group}} -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} ExecStartPre=/usr/share/elasticsearch/bin/elasticsearch-systemd-pre-exec {% endif %} ExecStart={{es_home}}/bin/elasticsearch \ -p ${PID_DIR}/elasticsearch.pid \ -{% if (es_version | version_compare('6.0.0', '<')) %} +{% if (es_version is version('6.0.0', '<')) %} -Edefault.path.logs=${LOG_DIR} \ -Edefault.path.data=${DATA_DIR} \ -Edefault.path.conf=${CONF_DIR} \ diff --git a/ansible/roles/log-es-azure-restore/tasks/main.yml b/ansible/roles/log-es-azure-restore/tasks/main.yml index f45a97587b2a857fa5971593a180a34791adec35..8d06fec321c05e47ce9ebfcd2f33766c412baca6 100644 --- a/ansible/roles/log-es-azure-restore/tasks/main.yml +++ b/ansible/roles/log-es-azure-restore/tasks/main.yml @@ -1,7 +1,7 @@ --- - name: Set azure snapshot for the first time uri: - url: "http://{{ es_restore_host }}:9200/_snapshot/azurebackup" + url: "http://{{ es_restore_host }}:9200/_snapshot/{{ snapshot_base_path }}" method: PUT body: "{{ snapshot_create_request_body | to_json }}" headers: @@ -9,12 +9,12 @@ - name: Restore ES from Azure backup uri: - url: "http://{{ es_restore_host }}:9200/_snapshot/azurebackup/{{snapshot_number}}/_restore" + url: "http://{{ es_restore_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{snapshot_number}}/_restore" method: POST - name: "Wait for restore to be completed" uri: - url: "http://{{ es_restore_host }}:9200/_snapshot/azurebackup/{{snapshot_number}}/_status" + url: "http://{{ es_restore_host }}:9200/_snapshot/{{ snapshot_base_path }}/{{snapshot_number}}/_status" method: GET return_content: yes status_code: 200 diff --git a/ansible/roles/log-es6/defaults/main.yml b/ansible/roles/log-es6/defaults/main.yml index bb239c3ead1d08f56b2fc1476837101bcd46125b..be7451275cf4cf27764820e682feb9684c896e31 100644 --- a/ansible/roles/log-es6/defaults/main.yml +++ b/ansible/roles/log-es6/defaults/main.yml @@ -15,7 +15,6 @@ es_start_service: true es_java_install: "{{ false if (es_version is version('7.0.0', '>=')) else true }}" update_java: false es_restart_on_change: true -es_plugins_reinstall: false es_templates: false es_user: elasticsearch es_group: elasticsearch @@ -69,3 +68,8 @@ es_ssl_verification_mode: "certificate" es_validate_certs: "yes" es_delete_unmanaged_file: true es_delete_unmanaged_native: true +es_plugins_reinstall: true +es_plugins: + - plugin: "repository-azure" + - plugin: "repository-s3" + - plugin: "repository-gcs" diff --git a/ansible/roles/log-es6/tasks/main.yml b/ansible/roles/log-es6/tasks/main.yml index 185212662b0bac9cfe967db46beafe8d8cff2eb4..646947abee093053611499c54a832d9ea4f0e7ca 100644 --- a/ansible/roles/log-es6/tasks/main.yml +++ b/ansible/roles/log-es6/tasks/main.yml @@ -59,6 +59,21 @@ tags: - xpack +- name: include plugins/create-keystore.yml + include: plugins/create-keystore.yml + +- name: include plugins/repository-azure.yml + include: plugins/repository-azure.yml + when: cloud_service_provider == "azure" + +- name: include plugins/repository-s3.yml + include: plugins/repository-s3.yml + when: cloud_service_provider == "aws" + +- name: include plugins/repository-gcs.yml + include: plugins/repository-gcs.yml + when: cloud_service_provider == "gcloud" + - name: include elasticsearch-ssl.yml include: elasticsearch-ssl.yml when: es_enable_http_ssl or es_enable_transport_ssl diff --git a/ansible/roles/log-es6/tasks/plugins/create-keystore.yml b/ansible/roles/log-es6/tasks/plugins/create-keystore.yml new file mode 100644 index 0000000000000000000000000000000000000000..80d2ca536e7976744cbba520b37b4efbb3606de1 --- /dev/null +++ b/ansible/roles/log-es6/tasks/plugins/create-keystore.yml @@ -0,0 +1,13 @@ +--- +- name: Check if elasticsearch keystore exists or not + become: yes + stat: + path: "{{ es_conf_dir }}/elasticsearch.keystore" + register: elasticsearch_keystore_file + +- name: Create the elasticsearch keystore if not exists + become: yes + command: "{{es_home}}/bin/elasticsearch-keystore create" + environment: + ES_PATH_CONF: "{{ es_conf_dir }}" + when: elasticsearch_keystore_file.stat.exists == false diff --git a/ansible/roles/log-es6/tasks/plugins/repository-azure.yml b/ansible/roles/log-es6/tasks/plugins/repository-azure.yml new file mode 100644 index 0000000000000000000000000000000000000000..9c3b9d3774cbf917bbe32c427fe20c6a5b299637 --- /dev/null +++ b/ansible/roles/log-es6/tasks/plugins/repository-azure.yml @@ -0,0 +1,15 @@ +--- +- name: Add default azure account name for backups + become: yes + shell: echo "{{ azure_management_storage_account_name }}" | {{ es_home }}/bin/elasticsearch-keystore add -f azure.client.default.account + no_log: True + environment: + ES_PATH_CONF: "{{ es_conf_dir }}" + + +- name: Add default azure account key for backups + become: yes + shell: echo "{{ azure_management_storage_account_key }}" | {{ es_home }}/bin/elasticsearch-keystore add -f azure.client.default.key + no_log: True + environment: + ES_PATH_CONF: "{{ es_conf_dir }}" \ No newline at end of file diff --git a/ansible/roles/log-es6/tasks/plugins/repository-gcs.yml b/ansible/roles/log-es6/tasks/plugins/repository-gcs.yml new file mode 100644 index 0000000000000000000000000000000000000000..81078e173dcb59d7fa5ae1a6386f7db73c7b04e4 --- /dev/null +++ b/ansible/roles/log-es6/tasks/plugins/repository-gcs.yml @@ -0,0 +1,18 @@ +--- +- name: Create the gcs service account file from variable + become: yes + copy: + dest: "{{ es_conf_dir }}/gcs_management_bucket_service_account.json" + content: "{{ gcs_management_bucket_service_account }}" + +- name: Add gcs service account file to keystore + become: yes + shell: "{{ es_home }}/bin/elasticsearch-keystore add-file -f gcs.client.default.credentials_file {{ es_conf_dir }}/gcs_management_bucket_service_account.json" + no_log: True + environment: + ES_PATH_CONF: "{{ es_conf_dir }}" + +- name: Remove the service account file + file: + path: "{{ es_conf_dir }}/gcs_management_bucket_service_account.json" + state: absent \ No newline at end of file diff --git a/ansible/roles/log-es6/tasks/plugins/repository-s3.yml b/ansible/roles/log-es6/tasks/plugins/repository-s3.yml new file mode 100644 index 0000000000000000000000000000000000000000..344af29e6ea9b06a70035557b7e2b20220e36640 --- /dev/null +++ b/ansible/roles/log-es6/tasks/plugins/repository-s3.yml @@ -0,0 +1,14 @@ +--- +- name: Add default aws account name for backups + become: yes + shell: echo "{{ aws_management_bucket_user_access_key }}" | {{ es_home }}/bin/elasticsearch-keystore add -f s3.client.default.access_key + no_log: True + environment: + ES_PATH_CONF: "{{ es_conf_dir }}" + +- name: Add default aws account key for backups + become: yes + shell: echo "{{ aws_management_bucket_user_secret_key }}" | {{ es_home }}/bin/elasticsearch-keystore add -f s3.client.default.secret_key + no_log: True + environment: + ES_PATH_CONF: "{{ es_conf_dir }}" diff --git a/ansible/roles/ml-analytics-service/defaults/main.yml b/ansible/roles/ml-analytics-service/defaults/main.yml index 89446f5c2bab4ef72192cbdeca845cca0e448a52..4cda4a2d7a240392105e7152c71b7ef6d8d175e7 100755 --- a/ansible/roles/ml-analytics-service/defaults/main.yml +++ b/ansible/roles/ml-analytics-service/defaults/main.yml @@ -49,7 +49,7 @@ ml_analytics_project_output_dir: "{{ WORKDIR }}/source/projects/output" ml_analytics_observation_status_output_dir: "{{ WORKDIR }}/source/observations/status/output" ml_analytics_api_authorization_key: "{{ml_api_auth_token | default('sunbird_api_auth_token')}}" ml_analytics_api_access_token: "{{ml_api_access_token | default('ml_core_internal_access_token')}}" -ml_analytics_druid_observation_status_injestion_spec : '{"type":"index","spec":{"ioConfig":{"type":"index","inputSource":{"type": "azure","uris": ["azure://telemetry-data-store/observation/status/sl_observation_status.json"]},"inputFormat":{"type":"json"}},"tuningConfig":{"type":"index","partitionsSpec":{"type":"dynamic"}},"dataSchema":{"dataSource":"sl-observation-status","granularitySpec":{"type":"uniform","queryGranularity":"DAY","rollup":false,"segmentGranularity":"DAY"},"timestampSpec":{"column":"updatedAt","format":"auto"},"dimensionsSpec":{"dimensions":["status","entity_externalId","entity_id","entity_type","solution_id","solution_externalId","submission_id","entity_name","solution_name","role_title","school_name","school_code","school_externalId","state_name","state_code","state_externalId","district_name","district_code","district_externalId","block_name","block_code","block_externalId","cluster_name","cluster_code","cluster_externalId","completedDate","channel","parent_channel","program_id","program_externalId","program_name","app_name","user_id","private_program","solution_type","organisation_name","ecm_marked_na","board_name","updatedAt","organisation_id","user_type"]},"metricsSpec":[]}}}' +ml_analytics_druid_observation_status_injestion_spec : '{"type":"index","spec":{"ioConfig":{"type":"index","inputSource":{"type": "azure","uris": ["azure://telemetry-data-store/observation/status/sl_observation_status.json"]},"inputFormat":{"type":"json"}},"tuningConfig":{"type":"index","partitionsSpec":{"type":"dynamic"}},"dataSchema":{"dataSource":"sl-observation-status","granularitySpec":{"type":"uniform","queryGranularity":"DAY","rollup":false,"segmentGranularity":"DAY"},"timestampSpec":{"column":"updatedAt","format":"auto"},"dimensionsSpec":{"dimensions":["status","entity_externalId","entity_id","entity_type","solution_id","solution_externalId","submission_id","entity_name","solution_name","role_title","school_name","school_code","school_externalId","state_name","state_code","state_externalId","district_name","district_code","district_externalId","block_name","block_code","block_externalId","cluster_name","cluster_code","cluster_externalId","completedDate","channel","parent_channel","program_id","program_externalId","program_name","app_name","user_id","private_program","solution_type","organisation_name","ecm_marked_na","board_name","updatedAt","organisation_id","user_type","observed_school_name","observed_school_id","observed_school_code","observed_state_name","observed_state_id","observed_state_code","observed_district_name","observed_district_id","observed_district_code","observed_block_name","observed_block_id","observed_block_code","observed_cluster_name","observed_cluster_id","observed_cluster_code"]},"metricsSpec":[]}}}' ml_analytics_druid_project_injestion_spec : '{"type":"index","spec":{"ioConfig":{"type":"index","inputSource":{"type": "azure","uris": ["azure://telemetry-data-store/projects/sl_projects.json"]},"inputFormat":{"type":"json"}},"tuningConfig":{"type":"index","partitionsSpec":{"type":"dynamic"}},"dataSchema":{"dataSource":"sl-project","granularitySpec":{"type":"uniform","queryGranularity":"DAY","rollup":false,"segmentGranularity":"DAY"},"timestampSpec":{"column":"project_updated_date","format":"auto"},"dimensionsSpec":{"dimensions":[]},"metricsSpec":[]}}}' ml_analytics_azure_sas_token: "{{ sunbird_private_storage_account_key }}" ml_analytics_druid_distinctCnt_obs_injestion_spec: '{"type":"index","spec":{"ioConfig":{"type":"index","inputSource":{"type":"azure","uris":["azure://telemetry-data-store/observation/distinctCount/ml_observation_distinctCount_status.json"]},"inputFormat":{"type":"json"}},"tuningConfig":{"type":"index","partitionsSpec":{"type":"dynamic"}},"dataSchema":{"dataSource":"ml-obs-status","granularitySpec":{"type":"uniform","queryGranularity":"none","rollup":false,"segmentGranularity":"DAY"},"timestampSpec":{"column":"time_stamp","format":"auto"},"dimensionsSpec":{"dimensions":[{"type":"string","name":"program_name"},{"type":"string","name":"program_id"},{"type":"string","name":"solution_name"},{"type":"string","name":"solution_id"},{"type":"string","name":"status"},{"type":"string","name":"state_name"},{"type":"string","name":"state_externalId"},{"type":"string","name":"district_name"},{"type":"string","name":"district_externalId"},{"type":"string","name":"organisation_name"},{"type":"string","name":"organisation_id"},{"type":"string","name":"parent_channel"},{"type":"string","name":"solution_type"},{"type":"string","name":"private_program"},{"type":"long","name":"unique_submissions"},{"type":"long","name":"unique_entities"},{"type":"long","name":"unique_users"},{"type":"string","name":"time_stamp"}]},"metricsSpec":[]}}}' @@ -79,7 +79,7 @@ ml_analytics_AWS_access_key: "{{ ml_AWS_access_key | default('') }}" ml_analytics_AWS_secret_access_key: "{{ ml_AWS_secret_access_key | default('') }}" ml_analytics_AWS_region_name: "{{ ml_AWS_region_name | default('') }}" ml_analytics_AWS_bucket_name: "{{ ml_AWS_bucket_name | default('') }}" -ml_analytics_druid_distinctCnt_prglevel_projects_status_injestion_spec : : '{"type":"index","spec":{"ioConfig":{"type":"index","inputSource":{"type":"azure","uris":["azure://telemetry-data-store/projects/distinctCountPrglevel/ml_projects_distinctCount_prgmlevel.json"]},"inputFormat":{"type":"json"}},"tuningConfig":{"type":"index","partitionsSpec":{"type":"dynamic"}},"dataSchema":{"dataSource":"ml-project-programLevel-status","granularitySpec":{"type":"uniform","queryGranularity":"none","rollup":false,"segmentGranularity":"DAY"},"timestampSpec":{"column":"time_stamp","format":"auto"},"dimensionsSpec":{"dimensions":[{"type":"string","name":"program_name"},{"type":"string","name":"program_id"},{"type":"string","name":"status_of_project"},{"type":"string","name":"state_name"},{"type":"string","name":"state_externalId"},{"type":"string","name":"private_program"},{"type":"string","name":"project_created_type"},{"type":"string","name":"parent_channel"},{"type":"long","name":"unique_projects"},{"type":"long","name":"unique_users"},{"type":"long","name":"no_of_imp_with_evidence"},{"type":"string","name":"time_stamp"}]},"metricsSpec":[]}}}' +ml_analytics_druid_distinctCnt_prglevel_projects_status_injestion_spec : '{"type":"index","spec":{"ioConfig":{"type":"index","inputSource":{"type":"azure","uris":["azure://telemetry-data-store/projects/distinctCountPrglevel/ml_projects_distinctCount_prgmlevel.json"]},"inputFormat":{"type":"json"}},"tuningConfig":{"type":"index","partitionsSpec":{"type":"dynamic"}},"dataSchema":{"dataSource":"ml-project-programLevel-status","granularitySpec":{"type":"uniform","queryGranularity":"none","rollup":false,"segmentGranularity":"DAY"},"timestampSpec":{"column":"time_stamp","format":"auto"},"dimensionsSpec":{"dimensions":[{"type":"string","name":"program_name"},{"type":"string","name":"program_id"},{"type":"string","name":"status_of_project"},{"type":"string","name":"state_name"},{"type":"string","name":"state_externalId"},{"type":"string","name":"private_program"},{"type":"string","name":"project_created_type"},{"type":"string","name":"parent_channel"},{"type":"long","name":"unique_projects"},{"type":"long","name":"unique_users"},{"type":"long","name":"no_of_imp_with_evidence"},{"type":"string","name":"time_stamp"}]},"metricsSpec":[]}}}' ml_analytics_projects_distinctCnt_prglevel_output_dir: "{{ WORKDIR }}/source/projects/distinctCountPrglevel/output" ml_analytics_projects_distinctCnt_prglevel_azure_blob_path: "projects/distinctCountPrglevel/" ml_analytics_survey_status_output_dir : "{{ WORKDIR }}/source/survey/status/output" diff --git a/ansible/roles/ml-analytics-service/tasks/main.yml b/ansible/roles/ml-analytics-service/tasks/main.yml index 9c9bf79a9038881b1a7947ed26ce9aa157ff2522..fc6a9b0ddf283907cae5a544136f4a259c10f01b 100755 --- a/ansible/roles/ml-analytics-service/tasks/main.yml +++ b/ansible/roles/ml-analytics-service/tasks/main.yml @@ -120,10 +120,19 @@ - faust_survey.service - faust_survey_evidence.service -- name: CREATE THE CRON +- name: CREATE THE CRON BATCH INGESTION cron: name: "Run Batch Ingestion Job" user: "{{ USER }}" minute: "30" hour: "18" job: "{{ BASEPATH }}/ml-analytics-service/run.sh > {{ BASEPATH }}/ml-analytics-service/crontab_job.log" + +- name: CREATE THE CRON NVSK Data Upload + cron: + name: "NVSK Data Upload JOB" + user: "{{ USER }}" + minute: "30" + hour: "7" + weekday: "4" + job: "{{ BASEPATH }}/run_weekly.sh > {{ BASEPATH }}/ml-analytics-service/nvsk_data_weekly.logs" diff --git a/ansible/roles/stack-monitor-stateful/templates/elasticsearch_snapshots_exporter_config.yml b/ansible/roles/stack-monitor-stateful/templates/elasticsearch_snapshots_exporter_config.yml index aa13c4be67b06837d20747f5d668f5e7d6d77dfc..43b12d5220115805b788421dfeef3c13bbd94530 100644 --- a/ansible/roles/stack-monitor-stateful/templates/elasticsearch_snapshots_exporter_config.yml +++ b/ansible/roles/stack-monitor-stateful/templates/elasticsearch_snapshots_exporter_config.yml @@ -1,6 +1,6 @@ exporter_port: 9158 log_level: info -json_data_url: http://{{ groups['es'][0] }}:9200/_snapshot/azurebackup/_all +json_data_url: http://{{ groups['es'][0] }}:9200/_snapshot/{{ snapshot_base_path }}/_all metric_name_prefix: elasticsearch_snapshots metrics: - name: latest_successful_snapshot_timestamp diff --git a/ansible/roles/stack-monitor/templates/elasticsearch_snapshots_exporter_config.yml b/ansible/roles/stack-monitor/templates/elasticsearch_snapshots_exporter_config.yml index aa13c4be67b06837d20747f5d668f5e7d6d77dfc..43b12d5220115805b788421dfeef3c13bbd94530 100644 --- a/ansible/roles/stack-monitor/templates/elasticsearch_snapshots_exporter_config.yml +++ b/ansible/roles/stack-monitor/templates/elasticsearch_snapshots_exporter_config.yml @@ -1,6 +1,6 @@ exporter_port: 9158 log_level: info -json_data_url: http://{{ groups['es'][0] }}:9200/_snapshot/azurebackup/_all +json_data_url: http://{{ groups['es'][0] }}:9200/_snapshot/{{ snapshot_base_path }}/_all metric_name_prefix: elasticsearch_snapshots metrics: - name: latest_successful_snapshot_timestamp diff --git a/deploy/jenkins/jenkins-server-setup.sh b/deploy/jenkins/jenkins-server-setup.sh index ad2b3616713c6aed0219e98f40c0b63ddcde8eec..9f4e3440bff8f284a67bbfef0fef38870c57ca67 100755 --- a/deploy/jenkins/jenkins-server-setup.sh +++ b/deploy/jenkins/jenkins-server-setup.sh @@ -70,7 +70,7 @@ rm -rf node-v6.17.1-linux-x64* echo -e "\n\e[0;32m${bold}Installating Ansible${normal}" pip uninstall -y ansible -pip3 install ansible==2.8.19 +pip3 install ansible==2.10.7 echo -e "\n\e[0;32m${bold}Installating azure cli${normal}" apt-get install ca-certificates curl apt-transport-https lsb-release gnupg diff --git a/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/Core/jobs/ApplicationElasticsearchRestore/config.xml b/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/Core/jobs/ApplicationElasticsearchRestore/config.xml index 65ec68f8a1a8edf3b8e825925fa9be887b08bc45..1bc46ecfe8d08846afb895982622ea31f63e85d0 100644 --- a/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/Core/jobs/ApplicationElasticsearchRestore/config.xml +++ b/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/Core/jobs/ApplicationElasticsearchRestore/config.xml @@ -29,7 +29,7 @@ <name>SNAPSHOT_NUMBER</name> <description><font color=teal size=2>Enter Snapshot number to restore. curl command to get snapshot number: -curl http://localhost:9200/_snapshot/azurebackup/_all, Parse the json and get the valid snapshot number to restore</font></description> +curl http://localhost:9200/_snapshot/{{ snapshot_base_path }}/_all, Parse the json and get the valid snapshot number to restore</font></description> <defaultValue></defaultValue> <trim>false</trim> </hudson.model.StringParameterDefinition> diff --git a/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/DataPipeline/jobs/ElasticsearchRestore/config.xml b/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/DataPipeline/jobs/ElasticsearchRestore/config.xml index 2587780de44336b05a93e91bbcd5d65c6b014b52..6e186acc541d8f6014fef5a2ddec70e0a01eb996 100644 --- a/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/DataPipeline/jobs/ElasticsearchRestore/config.xml +++ b/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/DataPipeline/jobs/ElasticsearchRestore/config.xml @@ -36,7 +36,7 @@ <name>SNAPSHOT_NUMBER</name> <description><font color=teal size=2>Enter Snapshot number to restore. curl command to get snapshot number: -curl http://localhost:9200/_snapshot/azurebackup/_all, Parse the json and get the valid snapshot number to restore</font></description> +curl http://localhost:9200/_snapshot/{{ snapshot_base_path }}/_all, Parse the json and get the valid snapshot number to restore</font></description> <defaultValue></defaultValue> <trim>false</trim> </hudson.model.StringParameterDefinition> diff --git a/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/KnowledgePlatform/jobs/ElasticsearchRestore/config.xml b/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/KnowledgePlatform/jobs/ElasticsearchRestore/config.xml index 85428f56e814f11464675461217eb606d50fcb19..6add03b312c6673a24ebd7367bd40bf85a8a5790 100644 --- a/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/KnowledgePlatform/jobs/ElasticsearchRestore/config.xml +++ b/deploy/jenkins/jobs/OpsAdministration/jobs/dev/jobs/KnowledgePlatform/jobs/ElasticsearchRestore/config.xml @@ -29,7 +29,7 @@ <name>SNAPSHOT_NUMBER</name> <description><font color=teal size=2>Enter Snapshot number to restore. curl command to get snapshot number: -curl http://localhost:9200/_snapshot/azurebackup/_all, Parse the json and get the valid snapshot number to restore</font></description> +curl http://localhost:9200/_snapshot/{{ snapshot_base_path }}/_all, Parse the json and get the valid snapshot number to restore</font></description> <defaultValue></defaultValue> <trim>false</trim> </hudson.model.StringParameterDefinition> diff --git a/kubernetes/ansible/roles/kong-api/tasks/main.yml b/kubernetes/ansible/roles/kong-api/tasks/main.yml index d85575decee8350e12fc117c4612517ca27bd69d..5b9ff4d8a2a2f4fc35592048ca96c655b4d490b4 100644 --- a/kubernetes/ansible/roles/kong-api/tasks/main.yml +++ b/kubernetes/ansible/roles/kong-api/tasks/main.yml @@ -23,4 +23,5 @@ shell: "python /tmp/kong-api-scripts/kong_apis.py /tmp/kong_apis.json --kong-admin-api-url=http://{{ private_ingressgateway_ip }}/admin-api" - name: Reload kong - shell: kubectl get pod -l app=apimanager --namespace={{namespace}} -o name | xargs -I{} kubectl exec {} -- kong reload \ No newline at end of file + shell: kubectl get pod -l app=apimanager --namespace={{namespace}} -o name | xargs -I{} kubectl exec {} -- kong reload + ignore_errors: true diff --git a/kubernetes/ansible/roles/kong-consumer/tasks/main.yml b/kubernetes/ansible/roles/kong-consumer/tasks/main.yml index edb1b4c0a4feb4906600feaca07873b394931f60..f7772d26995518cc337125a23e70f08c303d2e34 100644 --- a/kubernetes/ansible/roles/kong-consumer/tasks/main.yml +++ b/kubernetes/ansible/roles/kong-consumer/tasks/main.yml @@ -50,4 +50,5 @@ - /tmp/jwt_token.txt - name: Reload kong - shell: kubectl get pod -l app=apimanager --namespace={{namespace}} -o name | xargs -I{} kubectl exec {} -- kong reload \ No newline at end of file + shell: kubectl get pod -l app=apimanager --namespace={{namespace}} -o name | xargs -I{} kubectl exec {} -- kong reload + ignore_errors: true diff --git a/kubernetes/ansible/roles/logging/templates/elasticsearch-curator.yaml b/kubernetes/ansible/roles/logging/templates/elasticsearch-curator.yaml index b411d48adb047a7d65ce5e8267c4b6f028243282..6253cd44e1e151886704269cc284e7b19a2bee32 100644 --- a/kubernetes/ansible/roles/logging/templates/elasticsearch-curator.yaml +++ b/kubernetes/ansible/roles/logging/templates/elasticsearch-curator.yaml @@ -8,7 +8,7 @@ cronjob: image: repository: untergeek/curator - tag: 5.8.1 + tag: 5.8.4 pullPolicy: IfNotPresent configMaps: diff --git a/private_repo/ansible/inventory/dev/Core/common.yml b/private_repo/ansible/inventory/dev/Core/common.yml index 48024937f1e1889cd4cfbba6d6ef57c16d6bae38..e54937985e00686ce10494fa649471e7308aa351 100644 --- a/private_repo/ansible/inventory/dev/Core/common.yml +++ b/private_repo/ansible/inventory/dev/Core/common.yml @@ -23,6 +23,19 @@ sunbird_public_storage_account_name: "change.azure.storage.account.name" sunbird_private_storage_account_name: "change.azure.storage.account.name" # Azure account name for storing private data (like reports, telemetry data) sunbird_artifact_storage_account_name: "change.azure.storage.account.name" # Azure account name for storing artifacts data (like jenkins build zip files) sunbird_management_storage_account_name: "change.azure.storage.account.name" # Azure account name for storing backup data (like cassandra backups) + +# Define the below if you are using Azure Cloud +# Management Storage Account +azure_management_storage_account_name: "{{ sunbird_management_storage_account_name }}" + +# Define the below if you are using AWS Cloud +# Management Storage Bucket +aws_management_bucket_name: "" + +# Define the below if you are using Google Cloud +# Management Storage Bucket +gcs_management_bucket_name: "" + # ------------------------------------------------------------------------------------------------------------ # # Cloud / Infra Specific values - Check these and update accordingly diff --git a/private_repo/ansible/inventory/dev/Core/secrets.yml b/private_repo/ansible/inventory/dev/Core/secrets.yml index b004ab86d2639d650ef27b4f828e1686ee15bd05..798aceb7e0a4b3dcc28d16d52d85b6a3816b420a 100644 --- a/private_repo/ansible/inventory/dev/Core/secrets.yml +++ b/private_repo/ansible/inventory/dev/Core/secrets.yml @@ -17,6 +17,22 @@ sunbird_artifact_storage_account_sas: "change.azure.storage.account.sas" sunbird_public_storage_account_sas: "change.azure.storage.account.sas" # SAS token value generated from above command sunbird_public_storage_account_key: "change.azure.storage.account.key" sunbird_private_storage_account_key: "change.azure.storage.account.key" +sunbird_management_storage_account_key: "change.azure.storage.account.key" + +# Define the below if you are using Azure Cloud +# Management Storage Account +azure_management_storage_account_key: "{{ sunbird_management_storage_account_key }}" + +# Define the below if you are using AWS Cloud +# Management Storage Bucket +aws_management_bucket_user_access_key: "" +aws_management_bucket_user_secret_key: "" + + +# Define the below if you are using Google Cloud +# Management Storage Bucket +gcs_management_bucket_service_account: | + # The proxy key and crt values should be padded to the right by a couple of spaces # Example: