-
Notifications
You must be signed in to change notification settings - Fork 0
/
40.2-playbook_restore_k8s_asset_copies.yml
87 lines (86 loc) · 3.15 KB
/
40.2-playbook_restore_k8s_asset_copies.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
- name: Get k8s Copies
hosts: localhost
gather_facts: no
connection: local
vars_files:
- ./vars/main.yml
tasks:
- name: Checking Restore Type
fail:
msg: "var restore_type must be of TO_EXISTING or TO_ALTERNATE"
when: restore_type is defined and restore_type is not search('TO_EXISTING','TO_ALTERNATE')
- name: Checking Required Variable ppdm_fqdn
fail:
msg: "We do not have ppdm fqdn set !"
when: (ppdm_fqdn is not defined) or (ppdm_fqdn|length <= 8)
- name: Checking Required Variable ppdm_new_password
fail:
msg: "We do not have ppdm_new_password set !"
when: (ppdm_new_password is not defined) or (ppdm_new_password|length == 0)
- name: Checking Required Variable namespace_name
fail:
msg: "We do not have the namespace_name set !"
when: (namespace_name is not defined) or (namespace_name|length <= 3)
- name: Checking Required Variable target_namespace_name
fail:
msg: "We do not have the target_namespace_name set !"
when: (target_namespace_name is not defined) or (target_namespace_name|length <= 3)
- name: Setting Base URL
set_fact:
ppdm_baseurl: "https://{{ ppdm_fqdn | regex_replace('^https://') }}"
- name: Get PPDM Token for https://{{ ppdm_fqdn | regex_replace('^https://') }}
include_role:
name: get_ppdm_token
vars:
ppdm_password: "{{ ppdm_new_password }}"
- debug:
msg: "{{ access_token }}"
verbosity: 1
name: do we have a token ?
- name: Get PPDM Assets
include_role:
name: get_ppdm_assets
vars:
#filter: details.k8s.namespace in ("mysql", "mysql-rh", "openshift-image-registry", "powerstore", "scale002", "testpowerstore") and subtype eq "K8S_PERSISTENT_VOLUME_CLAIM"
filter: name eq "{{ namespace_name }}" and type eq "KUBERNETES" and subtype eq "K8S_NAMESPACE" and lastAvailableCopyTime ne null
#filter: type eq "KUBERNETES" and protectionStatus eq "PROTECTED" and details.k8s.namespac eq "{{ namespace_name }}"
- name: Assets Result
debug:
msg: "{{ assets }}"
verbosity: 1
- name: Get PPDM Assetcopies
include_role:
name: get_ppdm_assetcopies
vars:
id: "{{ assets[0].id }}"
- name: Copies Result
debug:
msg: "{{ copies[0] }}"
verbosity: 0
- name: Restore K8S Assetcopies
include_role:
name: restore_ppdm_k8s_copies
vars:
copy: "{{ copies[0] }}"
asset: "{{ assets[0] }}"
message: "{{ ticket_reason | default('') }}"
target_namespace: "{{ target_namespace_name }}"
restoreType: "{{ restore_type | default('TO_ALTERNATE') }}"
- name: Restore Result
debug:
msg: "{{ restore }}"
verbosity: 0
- name: Wait Restore complete
include_role:
name: get_ppdm_activities
vars:
id: "{{ restore.activityId }}"
delay: 30
retries: 30
condition: result.json.state == "COMPLETED" or result.json.state == "FAILED"
when: wait_activity is defined and restore is defined
- name: Result
debug:
msg: "{{ activities }}"
verbosity: 0
when: activities is defined