Mohammed Naser | 0003fd0 | 2022-03-12 15:38:24 -0500 | [diff] [blame] | 1 | # Copyright (c) 2022 VEXXHOST, Inc. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 4 | # not use this file except in compliance with the License. You may obtain |
| 5 | # a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 11 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 12 | # License for the specific language governing permissions and limitations |
| 13 | # under the License. |
| 14 | |
| 15 | - name: install packages |
| 16 | ansible.builtin.apt: |
| 17 | name: ["udev", "ceph-osd"] |
| 18 | install_recommends: false |
| 19 | |
| 20 | - name: grab ceph fsid from monitors |
| 21 | delegate_to: "{{ groups[ceph_osd_mons_group][0] }}" |
| 22 | register: _ceph_fsid |
| 23 | changed_when: false |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 24 | ansible.builtin.command: ceph fsid |
Mohammed Naser | 0003fd0 | 2022-03-12 15:38:24 -0500 | [diff] [blame] | 25 | |
| 26 | - name: collect facts for all monitors |
| 27 | delegate_to: "{{ item }}" |
| 28 | delegate_facts: true |
| 29 | ansible.builtin.setup: |
| 30 | gather_subset: network |
| 31 | loop: "{{ groups[ceph_osd_mons_group] }}" |
| 32 | when: inventory_hostname == ansible_play_hosts_all[0] |
| 33 | |
| 34 | - name: generate basic configuration file |
| 35 | community.general.ini_file: |
| 36 | path: /etc/ceph/ceph.conf |
| 37 | section: global |
| 38 | option: "{{ item.option }}" |
| 39 | value: "{{ item.value }}" |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 40 | owner: ceph |
| 41 | group: ceph |
| 42 | mode: 0640 |
Mohammed Naser | 0003fd0 | 2022-03-12 15:38:24 -0500 | [diff] [blame] | 43 | loop: |
| 44 | - option: fsid |
| 45 | value: "{{ _ceph_fsid.stdout | trim }}" |
| 46 | - option: mon host |
| 47 | value: "{{ groups[ceph_osd_mons_group] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | join(',') }}" |
| 48 | |
| 49 | - name: grab bootstrap-osd from monitors |
| 50 | delegate_to: "{{ groups[ceph_osd_mons_group][0] }}" |
| 51 | register: _ceph_bootstrap_osd_keyring |
| 52 | changed_when: false |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 53 | ansible.builtin.command: ceph auth get client.bootstrap-osd |
Mohammed Naser | 0003fd0 | 2022-03-12 15:38:24 -0500 | [diff] [blame] | 54 | |
| 55 | - name: install bootstrap-osd keyring |
| 56 | ansible.builtin.copy: |
| 57 | content: "{{ _ceph_bootstrap_osd_keyring.stdout }}\n" |
| 58 | dest: /var/lib/ceph/bootstrap-osd/ceph.keyring |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 59 | owner: ceph |
| 60 | group: ceph |
| 61 | mode: 0640 |
Mohammed Naser | 0003fd0 | 2022-03-12 15:38:24 -0500 | [diff] [blame] | 62 | |
| 63 | - name: workaround to allow usage of loop devices |
| 64 | ansible.builtin.replace: |
| 65 | path: /usr/lib/python3/dist-packages/ceph_volume/util/disk.py |
| 66 | regexp: "'mpath']" |
| 67 | replace: "'mpath', 'loop']" |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 68 | owner: ceph |
| 69 | group: ceph |
| 70 | mode: 0640 |
Mohammed Naser | 0003fd0 | 2022-03-12 15:38:24 -0500 | [diff] [blame] | 71 | when: molecule | default(false) |
| 72 | |
| 73 | # NOTE(mnaser): https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/1917414/comments/30 |
| 74 | - name: workaround for aarch64 systems |
| 75 | community.general.ini_file: |
| 76 | path: /lib/systemd/system/ceph-osd@.service |
| 77 | section: Service |
| 78 | option: MemoryDenyWriteExecute |
| 79 | value: false |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 80 | owner: ceph |
| 81 | group: ceph |
| 82 | mode: 0644 |
Mohammed Naser | 0003fd0 | 2022-03-12 15:38:24 -0500 | [diff] [blame] | 83 | register: _ceph_aarch64_fix |
| 84 | when: ansible_architecture == 'aarch64' |
| 85 | |
| 86 | - name: reload systemd |
| 87 | ansible.builtin.service: |
| 88 | daemon_reload: "{{ _ceph_aarch64_fix.changed }}" |
| 89 | |
| 90 | - name: get which devices don't contain osds |
| 91 | register: _ceph_osd_check |
| 92 | failed_when: false |
| 93 | changed_when: false |
| 94 | ansible.builtin.command: /usr/sbin/ceph-volume lvm list {{ item }} |
| 95 | loop: "{{ ceph_osd_devices }}" |
| 96 | |
| 97 | - name: create osds for volumes which are not setup |
Mohammed Naser | 511c3fa | 2022-03-17 17:54:10 -0400 | [diff] [blame] | 98 | changed_when: true |
Mohammed Naser | 0003fd0 | 2022-03-12 15:38:24 -0500 | [diff] [blame] | 99 | ansible.builtin.command: /usr/sbin/ceph-volume lvm create --data {{ item }} |
| 100 | loop: "{{ _ceph_osd_check.results | selectattr('rc', 'equalto', 1) | map(attribute='item') }}" |