blob: 271d880f2a2f82ca9142fe90009ee50a75407668 [file] [log] [blame]
Mohammed Naser0003fd02022-03-12 15:38:24 -05001# 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
24 ansible.builtin.shell: ceph fsid
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 }}"
40 loop:
41 - option: fsid
42 value: "{{ _ceph_fsid.stdout | trim }}"
43 - option: mon host
44 value: "{{ groups[ceph_osd_mons_group] | map('extract', hostvars, ['ansible_default_ipv4', 'address']) | join(',') }}"
45
46- name: grab bootstrap-osd from monitors
47 delegate_to: "{{ groups[ceph_osd_mons_group][0] }}"
48 register: _ceph_bootstrap_osd_keyring
49 changed_when: false
50 ansible.builtin.shell: ceph auth get client.bootstrap-osd
51
52- name: install bootstrap-osd keyring
53 ansible.builtin.copy:
54 content: "{{ _ceph_bootstrap_osd_keyring.stdout }}\n"
55 dest: /var/lib/ceph/bootstrap-osd/ceph.keyring
56
57- name: workaround to allow usage of loop devices
58 ansible.builtin.replace:
59 path: /usr/lib/python3/dist-packages/ceph_volume/util/disk.py
60 regexp: "'mpath']"
61 replace: "'mpath', 'loop']"
62 when: molecule | default(false)
63
64# NOTE(mnaser): https://bugs.launchpad.net/ubuntu/+source/ceph/+bug/1917414/comments/30
65- name: workaround for aarch64 systems
66 community.general.ini_file:
67 path: /lib/systemd/system/ceph-osd@.service
68 section: Service
69 option: MemoryDenyWriteExecute
70 value: false
71 register: _ceph_aarch64_fix
72 when: ansible_architecture == 'aarch64'
73
74- name: reload systemd
75 ansible.builtin.service:
76 daemon_reload: "{{ _ceph_aarch64_fix.changed }}"
77
78- name: get which devices don't contain osds
79 register: _ceph_osd_check
80 failed_when: false
81 changed_when: false
82 ansible.builtin.command: /usr/sbin/ceph-volume lvm list {{ item }}
83 loop: "{{ ceph_osd_devices }}"
84
85- name: create osds for volumes which are not setup
86 ansible.builtin.command: /usr/sbin/ceph-volume lvm create --data {{ item }}
87 loop: "{{ _ceph_osd_check.results | selectattr('rc', 'equalto', 1) | map(attribute='item') }}"