-
Notifications
You must be signed in to change notification settings - Fork 370
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
91 additions
and
27 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
--- | ||
- name: Add gcs credentials file to keystore | ||
- name: Create the gcs service account file from variable | ||
become: yes | ||
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 | ||
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 |
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
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