]> git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/setup_mixed_type.yml
import ceph quincy 17.2.1
[ceph.git] / ceph / src / ceph-volume / ceph_volume / tests / functional / batch / playbooks / setup_mixed_type.yml
1 ---
2 - hosts: osds
3 become: yes
4 tasks:
5
6 - name: install lvm2
7 package:
8 name: lvm2
9 state: present
10 - name: tell lvm to ignore loop devices
11 lineinfile:
12 path: /etc/lvm/lvm.conf
13 line: "\tfilter = [ 'r|loop.*|' ]"
14 insertafter: 'devices {'
15 - name: lvm allow changes depsite duplicate PVIDs
16 lineinfile:
17 path: /etc/lvm/lvm.conf
18 line: ' allow_changes_with_duplicate_pvs = 1'
19 insertafter: '^devices {'
20 regexp: 'allow_changes_with_duplicate_pvs = 0'
21 - name: create mount points
22 command: "mkdir /opt/{{ item }}"
23 loop:
24 - vdd
25 - vde
26 ignore_errors: yes
27
28 - name: add part
29 shell: echo "type=83" | sfdisk /dev/{{ item }}
30 loop:
31 - vdd
32 - vde
33
34 - name: add fs
35 command: "mkfs.ext4 /dev/{{ item }}1"
36 loop:
37 - vdd
38 - vde
39
40 - name: mount additional drives
41 command: "mount /dev/{{ item }}1 /opt/{{ item }}"
42 loop:
43 - vdd
44 - vde
45
46 - name: create the nvme image systemd unit
47 copy:
48 content: |
49 [Unit]
50 Description=NVMe loop device
51 After=local-fs.target
52 Wants=local-fs.target
53
54 [Service]
55 Type=simple
56 ExecStart=/bin/bash /opt/ceph-nvme.sh
57 StandardOutput=journal
58 StandardError=journal
59
60 [Install]
61 WantedBy=multi-user.target
62 dest: "/etc/systemd/system/ceph-nvme.service"
63
64 - name: create the ceph-nvme startup script
65 copy:
66 content: |
67 set -x
68 set -e
69 mount /dev/vdd1 /opt/vdd
70 mount /dev/vde1 /opt/vde
71 modprobe nvmet
72 modprobe nvme_loop
73 modprobe nvme_fabrics
74 modprobe loop
75 losetup -v /dev/loop0 /opt/vdd/loop0_nvme0
76 losetup -v /dev/loop1 /opt/vde/loop1_nvme1
77 losetup -l
78 nvmetcli restore /opt/loop.json
79 nvme connect -t loop -n testnqn1 -q hostnqn
80 nvme connect -t loop -n testnqn2 -q hostnqn
81 nvme list
82 dest: "/opt/ceph-nvme.sh"
83
84 - name: ensure ceph-nvme is enabled
85 service:
86 name: ceph-nvme
87 state: stopped
88 enabled: yes
89
90 - name: install nvme dependencies
91 package:
92 name: "{{ item }}"
93 state: present
94 with_items:
95 - nvme-cli
96 - nvmetcli
97
98 - name: enable NVME kernel modules
99 modprobe:
100 name: "{{ item }}"
101 state: present
102 with_items:
103 - nvmet
104 - nvme_loop
105 - nvme_fabrics
106
107 - name: detach nvme files from loop devices
108 command: "losetup -d /dev/{{ item }}"
109 failed_when: false
110 loop:
111 - loop0
112 - loop1
113
114 - name: remove previous nvme files
115 file:
116 path: "{{ item }}"
117 state: absent
118 loop:
119 - /opt/vdd/loop0_nvme0
120 - /opt/vde/loop1_nvme1
121
122 - name: create 20GB sparse files for NVMe
123 command: "fallocate -l 20G {{ item }}"
124 loop:
125 - /opt/vdd/loop0_nvme0
126 - /opt/vde/loop1_nvme1
127
128 - name: setup loop devices with sparse files 0
129 command: "losetup /dev/loop0 /opt/vdd/loop0_nvme0"
130 failed_when: false
131
132 - name: setup loop devices with sparse files 1
133 command: "losetup /dev/loop1 /opt/vde/loop1_nvme1"
134 failed_when: false
135
136 - name: create the loop.json file for nvmetcli
137 copy:
138 content: |
139 {
140 "hosts": [
141 {
142 "nqn": "hostnqn"
143 }
144 ],
145 "ports": [
146 {
147 "addr": {
148 "adrfam": "",
149 "traddr": "",
150 "treq": "not specified",
151 "trsvcid": "",
152 "trtype": "loop"
153 },
154 "portid": 1,
155 "referrals": [],
156 "subsystems": [
157 "testnqn1",
158 "testnqn2"
159 ]
160 }
161 ],
162 "subsystems": [
163 {
164 "allowed_hosts": [
165 "hostnqn"
166 ],
167 "attr": {
168 "allow_any_host": "0"
169 },
170 "namespaces": [
171 {
172 "device": {
173 "nguid": "ef90689c-6c46-d44c-89c1-4067801309a8",
174 "path": "/dev/loop0"
175 },
176 "enable": 1,
177 "nsid": 1
178 }
179 ],
180 "nqn": "testnqn1"
181 },
182 {
183 "allowed_hosts": [
184 "hostnqn"
185 ],
186 "attr": {
187 "allow_any_host": "0"
188 },
189 "namespaces": [
190 {
191 "device": {
192 "nguid": "ef90689c-6c46-d44c-89c1-4067801309a7",
193 "path": "/dev/loop1"
194 },
195 "enable": 1,
196 "nsid": 2
197 }
198 ],
199 "nqn": "testnqn2"
200 }
201 ]
202 }
203 dest: "/opt/loop.json"
204
205 - name: setup the /dev/loop0 target with nvmetcli
206 command: nvmetcli restore /opt/loop.json
207
208 - name: connect the new target as an nvme device
209 command: "nvme connect -t loop -n testnqn{{ item }} -q hostnqn"
210 loop:
211 - 1
212 - 2
213
214 - name: debug output for nvme list
215 command: nvme list