5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 - name: create osd disk configuration
25 - name: get the ceph osd ids
26 shell: lsblk -r | grep ceph- | cut -d '-' -f2
27 register: ceph_osd_ids
29 - name: get the devices
30 shell: for part in $(lsblk -r | grep ceph- | awk -F[^A-Za-z][0-9*] '{print $1}');do find -L /sys/block -maxdepth 2 -name $part|cut -d'/' -f4;done
33 - name: get the by-path disks
34 shell: file /dev/disk/by-path/* | grep -w {{ item }} | head -n 1 | awk '{print $1}' | sed 's/.$//'
35 with_items: "{{ osd_devices.stdout_lines }}"
38 - name: get the disk size
39 shell: lsblk -r | grep -w {{ item }} | awk '{print $4}'
40 with_items: "{{ osd_devices.stdout_lines }}"
41 register: disk_size_tmp
43 - name: initialize list variables
50 - name: set by_path variable
52 by_path: "{{ by_path }} + {{ item.stdout_lines }} "
53 with_items: "{{ by_path_tmp.results }}"
55 - name: set disk_size variable
57 disk_size: "{{ disk_size }} + {{ item.stdout_lines }} "
58 with_items: "{{ disk_size_tmp.results }}"
60 - name: populate disk_config
62 disk_config: "{{ disk_config + [ {'osd_id': item.0, 'device': item.1, 'by-path': item.2, 'size': item.3, 'service_name': 'ceph-osd-disk-' + item.4 | string, 'systemd': 'ceph-osd@' + item.0 | string + '.service'} ] }}"
64 - "{{ ceph_osd_ids.stdout_lines }}"
65 - "{{ osd_devices.stdout_lines }}"
68 - "{{ by_path_disks['osd_disks_ids'] }}"
70 - name: dump disk_config variable
71 action: template src=osd_disk_configuration.j2 dest=/tmp/{{ hostname }}-disks.json mode=644