Reorganize and rejigger

This commit is contained in:
2023-09-01 15:42:19 -04:00
parent 5cbce17bd1
commit a922fe4df7
16 changed files with 378 additions and 367 deletions

View File

@ -0,0 +1,107 @@
---
- name: generate cluster FSID
command: uuidgen
register: fsid_raw
delegate_to: localhost
- set_fact:
fsid: "{{ fsid_raw.stdout }}"
- name: initialize bootstrap ceph.conf
file:
dest: /etc/ceph/ceph.conf
state: touch
- name: set global section in bootstrap ceph.conf
lineinfile:
dest: /etc/ceph/ceph.conf
line: "[global]"
state: present
- name: set fsid in bootstrap ceph.conf
lineinfile:
dest: /etc/ceph/ceph.conf
line: "fsid = {{ fsid }}"
state: present
- name: set mon initial members in bootstrap ceph.conf
lineinfile:
dest: /etc/ceph/ceph.conf
line: "mon initial members = {% for host in pvc_nodes if host.is_coordinator %}{{ host.hostname }}{% if not loop.last %},{% endif %}{% endfor %}"
state: present
- name: set mon hosts in bootstrap ceph.conf
lineinfile:
dest: /etc/ceph/ceph.conf
line: "mon host = {% for host in pvc_nodes if host.is_coordinator %}{{ host.cluster_ip }}{% if not loop.last %},{% endif %}{% endfor %}"
state: present
- 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
command: ceph-authtool --create-keyring /tmp/ceph-bootstrap/ceph.client.admin.keyring --gen-key -n client.admin --set-uid=0 --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'
- 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 }} /tmp/ceph-bootstrap/monmap
- name: add monitors to monmap
command: monmaptool --add {{ item.hostname }} {{ item.cluster_ip }} --fsid {{ fsid }} /tmp/ceph-bootstrap/monmap
with_items:
- "{{ pvc_nodes }}"
- 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:
- "public network = {{ pvc_cluster_subnet }}"
- "cluster network = {{ pvc_storage_subnet }}"
- "auth cluster required = cephx"
- "auth service required = cephx"
- "auth client required = cephx"
- "osd journal size = 2"
- "osd pool default size = 3"
- "osd pool default min size = 2"
- "osd pool default pg num = 512"
- "osd pool default pgp num = 512"
- "osd crush chooseleaf type = 1"
- name: collect bootstrapped Ceph files into the role
fetch:
src: /tmp/ceph-bootstrap/{{ item }}
dest: roles/pvc/files/ceph/{{ hostvars[inventory_hostname].group_names[0] }}/ceph/
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

View File

@ -0,0 +1,84 @@
---
- name: install packages
apt:
name:
- ceph-osd
- ceph-mds
- ceph-mon
- ceph-mgr
- radosgw
- libjemalloc2
state: latest
- name: install sysctl tweaks
template:
src: ceph/sysctl.conf.j2
dest: /etc/sysctl.d/pvc-ceph.conf
- name: activate sysctl tweaks
command: sysctl -p /etc/sysctl.d/pvc-ceph.conf
- name: install user limits overrides
template:
src: ceph/limits.conf.j2
dest: /etc/security/limits.d/99-pvc-ceph.conf
- name: install ceph default config
template:
src: ceph/default.conf.j2
dest: /etc/default/ceph
- name: create ceph configuration directory
file:
dest: /etc/ceph
state: directory
- include: ceph/bootstrap.yml
when: bootstrap is defined and bootstrap
run_once: yes
- name: install configurations
copy:
src: ceph/{{ hostvars[inventory_hostname].group_names[0] }}/ceph/{{ item }}
dest: /etc/ceph/{{ item }}
owner: ceph
group: ceph
mode: 0640
with_items:
- ceph.conf
- ceph.mon.keyring
- ceph.client.admin.keyring
- ceph.osd.bootstrap.keyring
- monmap
- name: create monitor data directory
file:
dest: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}
state: directory
owner: ceph
group: ceph
mode: 0750
when: newhost is defined and newhost
- name: populate monitor with map and keys
command: ceph-mon --mkfs -i {{ ansible_hostname }} --monmap /etc/ceph/monmap --keyring /etc/ceph/ceph.mon.keyring
become_user: ceph
when: newhost is defined and newhost
- name: touch monitor done file
file:
dest: /var/lib/ceph/mon/ceph-{{ ansible_hostname }}/done
state: touch
become_user: ceph
when: newhost is defined and newhost
- name: start and enable daemons
service:
name: "{{ item }}"
state: started
enabled: yes
with_items:
- ceph-mon@{{ ansible_hostname }}
- ceph-mgr@{{ ansible_hostname }}
- meta: flush_handlers