|
1 | 1 | ---
|
2 |
| -- name: Check snapshot repository |
3 |
| - uri: |
4 |
| - url: http://127.0.0.1:9200/_snapshot/ipfs_s3 |
5 |
| - status_code: 200, 404 |
6 |
| - register: snapshot_check |
7 |
| -- name: Check keystore |
8 |
| - command: /usr/share/elasticsearch/bin/elasticsearch-keystore list |
9 |
| - register: keystore |
10 |
| - failed_when: keystore.rc not in [0, 65] |
11 |
| -- name: Loading secrets |
12 |
| - include_vars: |
13 |
| - file: ../../vault/secrets.yml |
14 |
| - when: | |
15 |
| - keystore.rc == 65 or \ |
16 |
| - 's3.client.default.access_key' not in keystore.stdout" or \ |
17 |
| - 's3.client.default.secret_key' not in keystore.stdout |
18 |
| -- name: Create keystore |
19 |
| - command: /usr/share/elasticsearch/bin/elasticsearch-keystore create |
20 |
| - when: keystore.rc == 65 |
21 |
| -- name: Add S3 access key |
22 |
| - command: /usr/share/elasticsearch/bin/elasticsearch-keystore add s3.client.default.access_key --stdin |
23 |
| - args: |
24 |
| - stdin: "{{ s3_access_key }}" |
25 |
| - when: "'s3.client.default.access_key' not in keystore.stdout" |
26 |
| - register: added_access_key |
27 |
| -- name: Add S3 secret key |
28 |
| - command: /usr/share/elasticsearch/bin/elasticsearch-keystore add s3.client.default.secret_key --stdin |
29 |
| - args: |
30 |
| - stdin: "{{ s3_secret_key }}" |
31 |
| - when: "'s3.client.default.secret_key' not in keystore.stdout" |
32 |
| - register: added_secret_key |
33 |
| -- name: Restart elasticsearch |
34 |
| - systemd: daemon_reload=yes state=restarted name=elasticsearch |
35 |
| - when: added_access_key.changed or added_secret_key.changed |
36 |
| -- name: Wait for elasticsearch to be ready |
37 |
| - wait_for: |
38 |
| - host: 127.0.0.1 |
39 |
| - port: 9200 |
40 |
| -- name: Create snapshot repository |
41 |
| - uri: |
42 |
| - url: http://127.0.0.1:9200/_snapshot/ipfs_s3 |
43 |
| - method: PUT |
44 |
| - body_format: json |
45 |
| - body: | |
46 |
| - { |
47 |
| - "type": "s3", |
48 |
| - "settings": { |
49 |
| - "bucket": "ipfs-search-snapshots", |
50 |
| - "storage_class": "standard_ia" |
51 |
| - } |
52 |
| - } |
53 |
| - when: snapshot_check.status == 404 |
54 |
| -- name: Install snapshot script |
55 |
| - copy: src=ipfs-search-snapshot.sh dest=/usr/local/bin/ipfs-search-snapshot.sh mode=755 |
56 |
| -- name: Elasticsearch daily snapshot cronjob |
57 |
| - cron: |
58 |
| - name: "Elasticsearch snapshot" |
59 |
| - cron_file: /etc/crontab |
60 |
| - minute: 16 |
61 |
| - hour: 3 |
62 |
| - backup: yes |
63 |
| - user: nobody |
64 |
| - job: "/usr/local/bin/ipfs-search-snapshot.sh" |
| 2 | +- name: Configuring S3 snapshots |
| 3 | + import_tasks: s3.yml |
| 4 | + tags: |
| 5 | + - snapshots-s3 |
| 6 | +- name: Configuring disk snapshots |
| 7 | + import_tasks: disk.yml |
| 8 | + tags: |
| 9 | + - snapshots-disk |
0 commit comments