This repository has been archived by the owner on Feb 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
/
restore_backup.yml
107 lines (107 loc) · 3.75 KB
/
restore_backup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
- name: Copy the backup file to the engine VM for restore
copy:
src: "{{ he_restore_from_file }}"
dest: /root/engine_backup
owner: root
group: root
mode: 0600
- name: Run engine-backup
shell: >-
engine-backup --mode=restore
--log=/var/log/ovirt-engine/setup/restore-backup-$(date -u +%Y%m%d%H%M%S).log
--file=/root/engine_backup --provision-all-databases --restore-permissions
environment: "{{ he_cmd_lang }}"
register: engine_restore_out
changed_when: true
- debug: var=engine_restore_out
- name: Remove backup file
file:
state: absent
path: /root/engine_backup
- name: Remove previous hosted-engine VM
command: >-
psql -d engine -c "SELECT deletevm(vm_guid) FROM (SELECT vm_guid FROM vms WHERE origin=6) t"
environment: "{{ he_cmd_lang }}"
become: true
become_user: postgres
become_method: sudo
changed_when: true
register: db_remove_old_enginevm
- name: Update dynamic data for VMs on the host used to redeploy
command: >-
psql -d engine -c
"UPDATE vm_dynamic SET run_on_vds = NULL, status=0 /* Down */ WHERE run_on_vds IN
(SELECT vds_id FROM vds
WHERE upper(vds_unique_id)=upper('{{ hostvars[he_ansible_host_name]['unique_id_out']['stdout_lines']|first }}'))"
environment: "{{ he_cmd_lang }}"
become: true
become_user: postgres
become_method: sudo
changed_when: true
register: db_update_host_vms
- debug: var=db_update_host_vms
- name: Update dynamic data for VMs migrating to the host used to redeploy
command: >-
psql -d engine -c
"UPDATE vm_dynamic SET migrating_to_vds = NULL, status=0 /* Down */ WHERE migrating_to_vds IN
(SELECT vds_id FROM vds WHERE
upper(vds_unique_id)=upper('{{ hostvars[he_ansible_host_name]['unique_id_out']['stdout_lines']|first }}'))"
environment: "{{ he_cmd_lang }}"
become: true
become_user: postgres
become_method: sudo
changed_when: true
register: db_update_host_migrating_vms
- debug: var=db_update_host_migrating_vms
- name: Remove host used to redeploy
command: >-
psql -d engine -c
"SELECT deletevds(vds_id) FROM
(SELECT vds_id FROM vds WHERE
upper(vds_unique_id)=upper('{{ hostvars[he_ansible_host_name]['unique_id_out']['stdout_lines']|first }}')) t"
environment: "{{ he_cmd_lang }}"
become: true
become_user: postgres
become_method: sudo
changed_when: true
register: db_remove_he_host
- debug: var=db_remove_he_host
- name: Rename previous HE storage domain to avoid name conflicts
command: >-
psql -d engine -c
"UPDATE storage_domain_static SET
storage_name='{{ he_storage_domain_name }}_old_{{ ansible_date_time.iso8601_basic_short }}' WHERE
storage_name='{{ he_storage_domain_name }}'"
environment: "{{ he_cmd_lang }}"
become: true
become_user: postgres
become_method: sudo
changed_when: true
register: db_rename_he_sd
- debug: var=db_rename_he_sd
- name: Save original DisableFenceAtStartupInSec
shell: >-
set -euo pipefail && engine-config -g DisableFenceAtStartupInSec |
cut -d' ' -f2 > /root/DisableFenceAtStartupInSec.txt
environment: "{{ he_cmd_lang }}"
changed_when: true
- name: Update DisableFenceAtStartupInSec to prevent host fencing during the recovery
command: "engine-config -s DisableFenceAtStartupInSec=86400"
environment: "{{ he_cmd_lang }}"
changed_when: true
- name: Add lines to engine-setup answerfile for PKI renewal
lineinfile:
path: /root/ovirt-engine-answers
line: "{{ item }}"
with_items:
- "OVESETUP_PKI/renew=bool:{{ he_pki_renew_on_restore }}"
- "QUESTION/1/OVESETUP_SKIP_RENEW_PKI_CONFIRM=str:yes"
- name: remove version lock from the engine
file:
state: absent
path: /etc/yum/pluginconf.d/versionlock.list
- name: recreate versionlock empty file
file:
state: touch
path: /etc/yum/pluginconf.d/versionlock.list