From 2e0bfa03f1395af5485152f44017cf6b2f8e037d Mon Sep 17 00:00:00 2001 From: Keshav Prasad <keshavprasadms@gmail.com> Date: Tue, 6 Sep 2022 10:51:40 +0530 Subject: [PATCH] feat: adding aws snapshot module --- ansible/es.yml | 4 ++-- ansible/roles/es-aws-snapshot/defaults/main.yml | 4 ++-- ansible/roles/es-aws-snapshot/tasks/main.yml | 2 +- ansible/roles/es6/defaults/main.yml | 2 +- ansible/roles/es6/tasks/main.yml | 4 ++-- ansible/roles/es6/tasks/plugins/repository-gcs.yml | 2 +- ansible/roles/es6/tasks/plugins/repository-s3.yml | 6 +++++- private_repo/ansible/inventory/dev/Core/common.yml | 5 +++++ 8 files changed, 19 insertions(+), 10 deletions(-) diff --git a/ansible/es.yml b/ansible/es.yml index b1c45b6a1..17aef43a6 100644 --- a/ansible/es.yml +++ b/ansible/es.yml @@ -8,8 +8,8 @@ roles: - role: es-azure-snapshot when: cloud_provider == "azure" -# - role: es-aws-snapshot -# when: cloud_provider == "aws" + - role: es-aws-snapshot + when: cloud_provider == "aws" # - role: es-gcloud-snapshot # when: cloud_provider == "gcloud" - role: es5-snapshot-purge diff --git a/ansible/roles/es-aws-snapshot/defaults/main.yml b/ansible/roles/es-aws-snapshot/defaults/main.yml index ca782a7c5..4d9ff91c8 100644 --- a/ansible/roles/es-aws-snapshot/defaults/main.yml +++ b/ansible/roles/es-aws-snapshot/defaults/main.yml @@ -1,8 +1,8 @@ snapshot_create_request_body: { type: s3, settings: { - bucket: "{{ es_s3_backup_folder_name }}", - base_path: "{{ snapshot_base_path }}_{{ base_path_date }}" + bucket: "{{ aws_management_bucket_name }}", + base_path: "{{ es_s3_backup_folder_name }}/{{ snapshot_base_path }}_{{ base_path_date }}" } } diff --git a/ansible/roles/es-aws-snapshot/tasks/main.yml b/ansible/roles/es-aws-snapshot/tasks/main.yml index 3f274b7a4..d428f337a 100644 --- a/ansible/roles/es-aws-snapshot/tasks/main.yml +++ b/ansible/roles/es-aws-snapshot/tasks/main.yml @@ -17,7 +17,7 @@ # AZURE_SECRET: "{{ azure_management_client_secret }}" # delegate_to: localhost -- name: Create azure snapshot +- name: Create aws snapshot uri: url: "http://{{ es_snapshot_host }}:9200/_snapshot/{{ snapshot_base_path }}" method: PUT diff --git a/ansible/roles/es6/defaults/main.yml b/ansible/roles/es6/defaults/main.yml index 295f486ac..5f6c7a530 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" diff --git a/ansible/roles/es6/tasks/main.yml b/ansible/roles/es6/tasks/main.yml index a0d877d71..0c1ed0e3a 100644 --- a/ansible/roles/es6/tasks/main.yml +++ b/ansible/roles/es6/tasks/main.yml @@ -44,8 +44,8 @@ include: plugins/repository-azure.yml when: cloud_provider == "azure" -- name: include plugins/repository-aws.yml - include: plugins/repository-aws.yml +- name: include plugins/repository-s3.yml + include: plugins/repository-s3.yml when: cloud_provider == "aws" - name: include plugins/repository-gcs.yml diff --git a/ansible/roles/es6/tasks/plugins/repository-gcs.yml b/ansible/roles/es6/tasks/plugins/repository-gcs.yml index a39e8c16a..59da8461a 100644 --- a/ansible/roles/es6/tasks/plugins/repository-gcs.yml +++ b/ansible/roles/es6/tasks/plugins/repository-gcs.yml @@ -1,5 +1,5 @@ --- - name: Add gcs credentials file to keystore become: yes - shell: echo "{{ s3_management_bucket_access_key }}" | {{ es_home }}/bin/elasticsearch-keystore add-file -f gcs.client.default.credentials_file google_cloud_store_management_service_account.json + shell: echo "{{ gcs_management_bucket_service_account }}" | {{ es_home }}/bin/elasticsearch-keystore add-file -f gcs.client.default.credentials_file google_cloud_store_management_service_account.json no_log: True \ 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 index 9a25e490e..b5897792a 100644 --- a/ansible/roles/es6/tasks/plugins/repository-s3.yml +++ b/ansible/roles/es6/tasks/plugins/repository-s3.yml @@ -3,8 +3,12 @@ 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 \ No newline at end of file + no_log: True + environment: + ES_PATH_CONF: "{{ conf_dir }}" diff --git a/private_repo/ansible/inventory/dev/Core/common.yml b/private_repo/ansible/inventory/dev/Core/common.yml index 7696b56f1..3150b983d 100644 --- a/private_repo/ansible/inventory/dev/Core/common.yml +++ b/private_repo/ansible/inventory/dev/Core/common.yml @@ -33,6 +33,11 @@ azure_management_resource_group_name: "" azure_management_client_id: "" azure_management_storage_account_name: "" +# Define the below if you are using AWS Cloud +# Ansible AWS Module Variables +# Management Storage Bucket +aws_management_bucket_name: "" + # ------------------------------------------------------------------------------------------------------------ # # Cloud / Infra Specific values - Check these and update accordingly -- GitLab