blob: 54978a53e6e0fac182b4d926e6f920167b5bb76c (
plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
---
### Localhost
- hosts: forensics
gather_facts: false
collections:
- infinidat.infinibox
vars:
network_space: InfiniSafe-Fenced-Network # iSCSI
service: ISCSI_SERVICE
pool: infinisafe
volume: app_vol
snap: app_snap
host: forensic-validation-host
host_iqn: iqn.1993-08.org.debian:01:62ebda3b76cc # io-wt-35
ibox_portal: 172.31.32.145
ibox: ibox1521
ibox_iqn: iqn.2009-11.com.infinidat:storage:infinibox-sn-1521
tasks:
- name: Create {{ service }} network space named {{ network_space }}
infini_network_space:
name: "{{ network_space }}"
state: present
service: "{{ service }}"
interfaces:
- 1680
- 1679
- 1678
netmask: 19
network: 172.31.32.0
default_gateway: 172.31.63.254
# rate_limit: 8
# mtu: 1280
ips:
- 172.31.32.145
- 172.31.32.146
- 172.31.32.147
- 172.31.32.148
- 172.31.32.149
- 172.31.32.150
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
delegate_to: localhost
- name: Create forensic host {{ host }}
infini_host:
name: "{{ host }}"
state: present
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
delegate_to: localhost
- name: Map snapshot {{ snap }} to host {{ host }}
infini_map:
host: "{{ host }}"
volume: "{{ snap }}"
state: present
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
delegate_to: localhost
- name: Add port to host {{ host }}
infini_port:
host: "{{ host }}"
iqns: "{{ host_iqn }}"
state: present
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
delegate_to: localhost
### Forensics Host
- name: Connect forensics host {{ host }} to Infinibox {{ ibox }}
ansible.builtin.shell: |
iscsiadm --mode discoverydb --type sendtargets --portal {{ ibox_portal }} --discover
iscsiadm --mode node --targetname={{ ibox_iqn }} --op update --name=node.session.auth.username --value={{ user }}
iscsiadm --mode discovery --type sendtargets --portal {{ ibox_portal }} --op show
iscsiadm --mode node --targetname {{ ibox_iqn }} --portal {{ ibox_portal }} --login
rescan-scsi-bus.sh
changed_when: false
become: true
# Run forensic tests on snapshot {{ snap }}
- name: Forensically test snapshot {{ snap }} is clean using host {{ host }}
ansible.builtin.shell: |
true
changed_when: false
register: is_snapshot_clean
### Localhost
- name: debug
ansible.builtin.debug:
msg: Snapshot {{ snap }} PASSED testing
when: is_snapshot_clean.rc == 0
delegate_to: localhost
- name: debug
ansible.builtin.debug:
msg: Snapshot {{ snap }} FAILED testing. Do not use this snapshot.
when: is_snapshot_clean.rc != 0
delegate_to: localhost
- name: Restoring volume {{ volume }} from known clean snapshot {{ snap }}
infini_vol:
name: "{{ snap }}"
state: present
parent_volume_name: "{{ volume }}"
volume_type: snapshot
restore_volume_from_snapshot: true
user: "{{ user }}"
password: "{{ password }}"
system: "{{ system }}"
when: is_snapshot_clean.rc == 0
delegate_to: localhost
|