2024-02-14 18:14:02 +08:00
|
|
|
---
|
|
|
|
- name: Creates logical volumes for the bucket index or fs journals on a single device.
|
2018-08-09 05:48:42 +08:00
|
|
|
become: true
|
2019-04-01 23:46:15 +08:00
|
|
|
hosts: osds
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2018-08-09 21:09:41 +08:00
|
|
|
vars:
|
|
|
|
logfile: |
|
2019-04-11 16:01:15 +08:00
|
|
|
Suggested cut and paste under "lvm_volumes:" in "group_vars/osds.yml"
|
2018-08-09 21:09:41 +08:00
|
|
|
-----------------------------------------------------------------------------------------------------------
|
|
|
|
{% for lv in nvme_device_lvs %}
|
|
|
|
- data: {{ lv.lv_name }}
|
|
|
|
data_vg: {{ nvme_vg_name }}
|
|
|
|
journal: {{ lv.journal_name }}
|
|
|
|
journal_vg: {{ nvme_vg_name }}
|
|
|
|
{% endfor %}
|
|
|
|
{% for hdd in hdd_devices %}
|
|
|
|
- data: {{ hdd_lv_prefix }}-{{ hdd.split('/')[-1] }}
|
|
|
|
data_vg: {{ hdd_vg_prefix }}-{{ hdd.split('/')[-1] }}
|
|
|
|
journal: {{ hdd_journal_prefix }}-{{ hdd.split('/')[-1] }}
|
|
|
|
journal_vg: {{ nvme_vg_name }}
|
|
|
|
{% endfor %}
|
|
|
|
|
2018-07-24 21:33:09 +08:00
|
|
|
tasks:
|
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Include vars of lv_vars.yaml
|
|
|
|
ansible.builtin.include_vars:
|
|
|
|
file: lv_vars.yaml # noqa missing-import
|
|
|
|
failed_when: false
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
# ensure nvme_device is set
|
|
|
|
- name: Fail if nvme_device is not defined
|
|
|
|
ansible.builtin.fail:
|
|
|
|
msg: "nvme_device has not been set by the user"
|
|
|
|
when: nvme_device is undefined or nvme_device == 'dummy'
|
2018-10-29 14:01:25 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
# need to check if lvm2 is installed
|
|
|
|
- name: Install lvm2
|
|
|
|
ansible.builtin.package:
|
|
|
|
name: lvm2
|
|
|
|
state: present
|
|
|
|
register: result
|
|
|
|
until: result is succeeded
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
# Make entire nvme device a VG
|
|
|
|
- name: Add nvme device as lvm pv
|
|
|
|
community.general.lvg:
|
|
|
|
force: true
|
|
|
|
pvs: "{{ nvme_device }}"
|
|
|
|
pesize: 4
|
|
|
|
state: present
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create lvs for fs journals for the bucket index on the nvme device
|
|
|
|
community.general.lvol:
|
|
|
|
lv: "{{ item.journal_name }}"
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
|
|
|
size: "{{ journal_size }}"
|
|
|
|
pvs: "{{ nvme_device }}"
|
|
|
|
with_items: "{{ nvme_device_lvs }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create lvs for fs journals for hdd devices
|
|
|
|
community.general.lvol:
|
|
|
|
lv: "{{ hdd_journal_prefix }}-{{ item.split('/')[-1] }}"
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
|
|
|
size: "{{ journal_size }}"
|
|
|
|
with_items: "{{ hdd_devices }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create the lv for data portion of the bucket index on the nvme device
|
|
|
|
community.general.lvol:
|
|
|
|
lv: "{{ item.lv_name }}"
|
|
|
|
vg: "{{ nvme_vg_name }}"
|
|
|
|
size: "{{ item.size }}"
|
|
|
|
pvs: "{{ nvme_device }}"
|
|
|
|
with_items: "{{ nvme_device_lvs }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
# Make sure all hdd devices have a unique volume group
|
|
|
|
- name: Create vgs for all hdd devices
|
|
|
|
community.general.lvg:
|
|
|
|
force: true
|
|
|
|
pvs: "{{ item }}"
|
|
|
|
pesize: 4
|
|
|
|
state: present
|
|
|
|
vg: "{{ hdd_vg_prefix }}-{{ item.split('/')[-1] }}"
|
|
|
|
with_items: "{{ hdd_devices }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Create lvs for the data portion on hdd devices
|
|
|
|
community.general.lvol:
|
|
|
|
lv: "{{ hdd_lv_prefix }}-{{ item.split('/')[-1] }}"
|
|
|
|
vg: "{{ hdd_vg_prefix }}-{{ item.split('/')[-1] }}"
|
|
|
|
size: "{{ hdd_lv_size }}"
|
|
|
|
pvs: "{{ item }}"
|
|
|
|
with_items: "{{ hdd_devices }}"
|
2018-07-24 21:33:09 +08:00
|
|
|
|
2024-02-14 18:14:02 +08:00
|
|
|
- name: Write output for osds.yml
|
|
|
|
become: false
|
|
|
|
ansible.builtin.copy:
|
|
|
|
content: "{{ logfile }}"
|
|
|
|
dest: "{{ logfile_path }}"
|
|
|
|
mode: preserve
|
|
|
|
delegate_to: localhost
|