-
Notifications
You must be signed in to change notification settings - Fork 32
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
1 parent
536f209
commit 0a1f050
Showing
14 changed files
with
170 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- | ||
- name: "[VAULT] Restore" | ||
hosts: "{{ scope | default('hashistack_masters') }}" | ||
become: false | ||
gather_facts: false | ||
|
||
vars: | ||
ansible_ssh_user: "vault-snapshot" | ||
|
||
tasks: | ||
- name: "Vault" | ||
include_role: | ||
name: "vault" | ||
tasks_from: "__restore.yml" | ||
apply: | ||
tags: | ||
- vault | ||
tags: | ||
- vault | ||
|
||
|
||
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,18 @@ | ||
--- | ||
- name: "[VAULT] Snapshot" | ||
hosts: "hashistack_masters" | ||
become: true | ||
gather_facts: false | ||
|
||
tasks: | ||
- name: "Vault" | ||
include_role: | ||
name: "vault" | ||
tasks_from: "_inplace_init_unseal.yml" | ||
apply: | ||
tags: | ||
- vault | ||
tags: | ||
- vault | ||
|
||
|
||
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
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,11 +1,11 @@ | ||
--- | ||
- name: Restart vault | ||
- name: "Restart vault" | ||
systemd: | ||
name: vault | ||
state: restarted | ||
daemon_reload: true | ||
enabled: true | ||
|
||
- name: Update ca trust | ||
- name: "Update ca trust" | ||
command: >- | ||
{{ __hs_vault_update_trust_command }} |
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,51 @@ | ||
--- | ||
# Implementation of: | ||
# https://developer.hashicorp.com/vault/tutorials/standard-procedures/sop-restore | ||
- name: "Load collection common vars" | ||
import_role: | ||
name: "vault_vars" | ||
tags: | ||
- always | ||
|
||
- name: "Gather vault leader" | ||
uri: | ||
url: "{{ __hs_vault_api.leader }}" | ||
return_content: true | ||
headers: | ||
X-Vault-Token: "{{ hs_vault_snapshot_token }}" | ||
environment: | ||
SSL_CERT_FILE: /etc/ssl/certs/ca-certificates.crt | ||
register: _current_vault_leader | ||
|
||
- name: "Cook variables" | ||
set_fact: | ||
_hs_vault_is_leader: >- | ||
{{ _current_vault_leader.json.leader_address == __hs_vault_conf_api_addr }} | ||
- name: "Synchronize duplicity datastore" | ||
Check failure on line 25 in roles/vault/tasks/__restore.yml
|
||
synchronize: | ||
src: "{{ hs_workspace_local_backup_dir }}/vault/" | ||
mode: push | ||
dest: "{{ __hs_vault_snapshot_duplicity_dir }}/" | ||
rsync_opts: '-e "ssh -F {{ hs_workspace_root }}/ssh.cfg"' | ||
when: _hs_vault_is_leader | ||
|
||
- name: "Duplicity restore" | ||
shell: | ||
cmd: >- | ||
duplicity restore | ||
file://{{ __hs_vault_snapshot_duplicity_dir }} | ||
{{ __hs_vault_snapshot_home_dir }}/snapshots | ||
executable: /usr/bin/bash | ||
environment: | ||
PASSPHRASE: "{{ hs_vault_snapshot_passphrase }}" | ||
when: _hs_vault_is_leader | ||
|
||
- name: "Vault restore" | ||
shell: | ||
cmd: >- | ||
source {{ __hs_vault_snapshot_home_dir }}/.bash_profile && | ||
vault operator raft snapshot restore -force {{ __hs_vault_snapshot_dir }}/vault.snapshot | ||
executable: /usr/bin/bash | ||
when: _hs_vault_is_leader | ||
|
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 |
---|---|---|
@@ -1,20 +1,20 @@ | ||
--- | ||
- name: Unarchive | ||
- name: "Unarchive" | ||
unarchive: | ||
src: "{{ __hs_vault_local_archive_path }}" | ||
dest: "/usr/bin" | ||
creates: "/usr/bin/vault" | ||
|
||
- name: Set permissions on vault binary | ||
- name: "Set permissions on vault binary" | ||
file: | ||
path: "/usr/bin/vault" | ||
owner: root | ||
group: vault | ||
mode: 0750 | ||
|
||
- name: Render system service | ||
- name: "Render system service" | ||
template: | ||
src: vault.service.j2 | ||
src: "vault.service.j2" | ||
dest: "/lib/systemd/system/vault.service" | ||
mode: 0644 | ||
notify: Restart vault |
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