Skip to content

Instantly share code, notes, and snippets.

@logan2211
Created December 21, 2016 01:29
Show Gist options
  • Save logan2211/f2383ddd5d80a15f66c2f030c8255621 to your computer and use it in GitHub Desktop.
Save logan2211/f2383ddd5d80a15f66c2f030c8255621 to your computer and use it in GitHub Desktop.
Ceph OSD auto classification
ceph_layouts:
4HDD:
devices:
- /dev/sda
- /dev/sdb
- /dev/sdc
- /dev/sdd
'1SSD+4HDD':
journal_size: 10000
raw_multi_journal: true
raw_journal_devices:
- /dev/sda
- /dev/sda
- /dev/sda
- /dev/sda
devices:
- /dev/sdb
- /dev/sdc
- /dev/sdd
- /dev/sde
1SSD:
journal_collocation: true
journal_size: 10000
devices:
- /dev/sda
2SSD:
journal_collocation: true
journal_size: 10000
devices:
- /dev/sda
- /dev/sdb
- name: Install ceph osds
hosts: "{{ osd_group_name }}"
pre_tasks:
- name: Set HDD count fact
set_fact:
hdd_count: "{{ ansible_devices | dictsort | selectattr('1.removable', 'equalto', '0') | map(attribute='1.rotational') | map('int') | sum }}"
tags:
- ceph
- ceph-osd
- ceph-osd-layout
- name: Set SSD count fact
set_fact:
ssd_count: "{{ ansible_devices | dictsort | selectattr('1.removable', 'equalto', '0') | list | length - hdd_count | int }}"
tags:
- ceph
- ceph-osd
- ceph-osd-layout
- name: Try to set layout automatically if none is specified
set_fact:
ceph_layout: "{% if ssd_count|int > 0 %}{{ ssd_count }}SSD{% endif %}{% if ssd_count|int > 0 and hdd_count|int > 0 %}+{% endif %}{% if hdd_count|int > 0 %}{{ hdd_count }}HDD{% endif %}"
when: ceph_layout is not defined
tags:
- ceph
- ceph-osd
- ceph-osd-layout
- name: Set host facts for specified ceph layout
set_fact:
journal_size: "{{ ceph_layouts[ceph_layout]['journal_size'] | default(omit) }}"
journal_collocation: "{{ ceph_layouts[ceph_layout]['journal_collocation'] | default(omit) }}"
devices: "{{ ceph_layouts[ceph_layout]['devices'] | default(omit) }}"
raw_multi_journal: "{{ ceph_layouts[ceph_layout]['raw_multi_journal'] | default(omit) }}"
raw_journal_devices: "{{ ceph_layouts[ceph_layout]['raw_journal_devices'] | default(omit) }}"
when:
- ceph_layout is defined
- ceph_layouts[ceph_layout] is defined
- ceph_autolayout_disable is not defined
tags:
- ceph
- ceph-osd
- ceph-osd-layout
roles:
- { role: "ceph-osd", tags: [ "ceph", "ceph-osd" ] }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment