]> git.proxmox.com Git - ceph.git/blob - ceph/src/ceph-volume/ceph_volume/tests/functional/batch/playbooks/setup_mixed_type.yml
update sources to 12.2.10
[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: create the nvme image systemd unit
7 copy:
8 content: |
9 [Unit]
10 Description=NVMe loop device
11 After=local-fs.target
12 Wants=local-fs.target
13
14 [Service]
15 Type=simple
16 ExecStart=/bin/bash /opt/ceph-nvme.sh
17 StandardOutput=journal
18 StandardError=journal
19
20 [Install]
21 WantedBy=multi-user.target
22 dest: "/etc/systemd/system/ceph-nvme.service"
23
24 - name: create the ceph-nvme startup script
25 copy:
26 content: |
27 set -x
28 set -e
29 modprobe nvmet
30 modprobe nvme_loop
31 modprobe nvme_fabrics
32 modprobe loop
33 losetup -v /dev/loop0 /opt/loop0_nvme0
34 losetup -l
35 nvmetcli restore /opt/loop.json
36 nvme connect -t loop -n testnqn -q hostnqn
37 nvme list
38 dest: "/opt/ceph-nvme.sh"
39
40 - name: ensure ceph-nvme is enabled
41 service:
42 name: ceph-nvme
43 state: stopped
44 enabled: yes
45
46 - name: install nvme dependencies
47 package:
48 name: "{{ item }}"
49 state: present
50 with_items:
51 - nvme-cli
52 - nvmetcli
53
54 - name: enable NVME kernel modules
55 modprobe:
56 name: "{{ item }}"
57 state: present
58 with_items:
59 - nvmet
60 - nvme_loop
61 - nvme_fabrics
62
63 - name: check if the nvme file is attached to loop0
64 command: losetup -l /dev/loop0
65 register: losetup_list
66
67 - name: detach current nvme0 file
68 command: losetup -d /dev/loop0
69 when: '"loop0_nvme0" in losetup_list.stdout'
70
71 - name: remove previous nvme0 file
72 file:
73 path: /opt/loop0_nvme0
74 state: absent
75
76 - name: create a 15GB sparse file for NVMe
77 command: fallocate -l 15G /opt/loop0_nvme0
78
79 - name: setup loop device with sparse file
80 command: losetup /dev/loop0 /opt/loop0_nvme0
81 when:
82 - '"loop0_nvme0" not in losetup_list.stdout'
83
84 - name: create the loop.json file for nvmetcli
85 copy:
86 content: |
87 {
88 "hosts": [
89 {
90 "nqn": "hostnqn"
91 }
92 ],
93 "ports": [
94 {
95 "addr": {
96 "adrfam": "",
97 "traddr": "",
98 "treq": "not specified",
99 "trsvcid": "",
100 "trtype": "loop"
101 },
102 "portid": 1,
103 "referrals": [],
104 "subsystems": [
105 "testnqn"
106 ]
107 }
108 ],
109 "subsystems": [
110 {
111 "allowed_hosts": [
112 "hostnqn"
113 ],
114 "attr": {
115 "allow_any_host": "0"
116 },
117 "namespaces": [
118 {
119 "device": {
120 "nguid": "ef90689c-6c46-d44c-89c1-4067801309a8",
121 "path": "/dev/loop0"
122 },
123 "enable": 1,
124 "nsid": 1
125 }
126 ],
127 "nqn": "testnqn"
128 }
129 ]
130 }
131 dest: "/opt/loop.json"
132
133 - name: setup the /dev/loop0 target with nvmetcli
134 command: nvmetcli restore /opt/loop.json
135
136 - name: connect the new target as an nvme device
137 command: nvme connect -t loop -n testnqn -q hostnqn
138
139 - name: debug output for nvme list
140 command: nvme list