pvc-ansible/roles/pvc/tasks/ceph/bootstrap.yml

120 lines
3.9 KiB
YAML
Raw Normal View History

2023-09-01 15:42:19 -04:00
---
- name: generate cluster FSID
command: uuidgen
register: fsid_raw
delegate_to: localhost
2023-09-01 15:42:22 -04:00
become: no
2023-09-01 15:42:19 -04:00
- set_fact:
fsid: "{{ fsid_raw.stdout }}"
2023-09-01 15:42:20 -04:00
- name: create bootstrap ceph.conf
file:
dest: /etc/ceph/ceph.conf
state: touch
2023-09-01 15:42:19 -04:00
- name: initialize bootstrap ceph.conf
lineinfile:
dest: /etc/ceph/ceph.conf
2023-09-01 15:42:20 -04:00
line: "{{ item }}"
2023-09-01 15:42:19 -04:00
state: present
2023-09-01 15:42:20 -04:00
with_items:
- "[global]"
- "fsid = {{ fsid }}"
- "mon initial members = {% for node in pvc_nodes if node.is_coordinator %}{{ node.hostname }}{% if not loop.last %},{% endif %}{% endfor %}"
2023-09-01 15:42:22 -04:00
- "mon host = {% for host in pvc_nodes if host.is_coordinator %}{{ host.storage_ip }}{% if not loop.last %},{% endif %}{% endfor %}"
2023-09-01 15:42:19 -04:00
- name: create temporary directory
file:
dest: /tmp/ceph-bootstrap
state: directory
- name: create mon keyring
command: ceph-authtool --create-keyring /tmp/ceph-bootstrap/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'
- name: create client admin keyring
2023-09-01 15:42:22 -04:00
command: ceph-authtool --create-keyring /tmp/ceph-bootstrap/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'
2023-09-01 15:42:19 -04:00
- name: add client admin keyring to mon keyring
command: ceph-authtool /tmp/ceph-bootstrap/ceph.mon.keyring --import-keyring /tmp/ceph-bootstrap/ceph.client.admin.keyring
- name: create OSD bootstrap keyring
command: ceph-authtool --create-keyring /tmp/ceph-bootstrap/ceph.osd.bootstrap.keyring --gen-key -n client.bootstrap-osd --cap mon 'profile bootstrap-osd'
- name: add OSD bootstrap keyring to mon keyring
command: ceph-authtool /tmp/ceph-bootstrap/ceph.mon.keyring --import-keyring /tmp/ceph-bootstrap/ceph.osd.bootstrap.keyring
- name: create monmap
command: monmaptool --create --fsid {{ fsid }} {% for node in pvc_nodes if node.is_coordinator %}--add {{ node.hostname }} {{ node.storage_ip }} {% endfor %} /tmp/ceph-bootstrap/monmap
2023-09-01 15:42:19 -04:00
- name: copy initial ceph.conf to the boostrap directory
copy:
src: /etc/ceph/ceph.conf
dest: /tmp/ceph-bootstrap/ceph.conf
remote_src: yes
- name: add additional configuration lines to ceph.conf
lineinfile:
dest: /tmp/ceph-bootstrap/ceph.conf
line: "{{ item }}"
state: present
with_items:
2023-09-01 15:42:22 -04:00
- "public network = {{ pvc_storage_subnet }}/{{ pvc_storage_netmask }}"
- "cluster network = {{ pvc_storage_subnet }}/{{ pvc_storage_netmask }}"
2023-09-01 15:42:19 -04:00
- "auth cluster required = cephx"
- "auth service required = cephx"
- "auth client required = cephx"
2023-09-01 15:42:20 -04:00
- "mon allow pool delete = 1"
- "osd max scrubs = 2"
- "osd scrub during recovery = false"
- "osd scrub sleep = 5"
- "osd max backfills = 8"
- "osd recovery sleep hdd = 0"
- "osd recovery sleep ssd = 0"
- "osd recovery sleep hybrid = 0"
2023-09-01 15:42:19 -04:00
- "osd pool default size = 3"
- "osd pool default min size = 2"
- "osd pool default pg num = 128"
- "osd pool default pgp num = 128"
- "osd pool default autoscale mode = off"
2023-09-01 15:42:19 -04:00
- "osd crush chooseleaf type = 1"
2023-09-01 15:42:24 -04:00
- "bluestore cache autotune = true"
- "rbd default features = 5"
2023-09-01 15:42:24 -04:00
- name: add single-node cluster options
lineinfile:
dest: /tmp/ceph-bootstrap/ceph.conf
line: "{{ item }}"
state: present
with_items:
- "osd pool default size = 2"
- "osd pool default min size = 1"
when: "{{ pvc_nodes | length }} == 1"
2023-09-01 15:42:24 -04:00
- name: add memory limit if requested
lineinfile:
dest: /tmp/ceph-bootstrap/ceph.conf
line: "{{ item }}"
state: present
with_items:
- "osd memory target = {{ pvc_osd_memory_limit }}"
when: pvc_osd_memory_limit is defined
2023-09-01 15:42:19 -04:00
- name: collect bootstrapped Ceph files into the role
fetch:
src: /tmp/ceph-bootstrap/{{ item }}
2023-09-01 15:42:26 -04:00
dest: files/{{ cluster_group }}/ceph/
2023-09-01 15:42:19 -04:00
flat: yes
with_items:
- ceph.conf
- ceph.mon.keyring
- ceph.client.admin.keyring
- ceph.osd.bootstrap.keyring
- monmap
- name: remove the temporary bootstrap directory
file:
dest: /tmp/ceph-bootstrap
state: absent
force: yes