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

182 lines
4.5 KiB
YAML
Raw Normal View History

2023-09-01 15:42:19 -04:00
---
- name: install packages
apt:
name:
- ceph-osd
- ceph-mds
- ceph-mon
- ceph-mgr
- radosgw
state: latest
2023-09-01 15:42:30 -04:00
register: apt_res
retries: 5
until: apt_res is success
2023-09-01 15:42:19 -04:00
- name: add admin users to ceph groups
user:
name: "{{ item.name }}"
groups: ceph
append: yes
with_items: "{{ admin_users }}"
2024-08-29 01:08:44 -04:00
ignore_errors: yes
2023-09-01 15:42:19 -04:00
- 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: do_bootstrap is defined and do_bootstrap
2023-09-01 15:42:19 -04:00
run_once: yes
- name: install configurations
copy:
src: ceph/{{ cluster_group }}/ceph/{{ item }}
2023-09-01 15:42:19 -04:00
dest: /etc/ceph/{{ item }}
owner: ceph
group: ceph
mode: 0640
notify:
- restart ceph-mon
- restart ceph-mgr
2023-09-01 15:42:19 -04:00
with_items:
- ceph.conf
- ceph.mon.keyring
- ceph.client.admin.keyring
- ceph.osd.bootstrap.keyring
- monmap
- name: create monitor and manager data directories
2023-09-01 15:42:19 -04:00
file:
dest: /var/lib/ceph/{{ item }}/ceph-{{ ansible_hostname }}
2023-09-01 15:42:19 -04:00
state: directory
owner: ceph
group: ceph
mode: 0750
with_items:
- mon
- mgr
2023-09-01 15:42:19 -04:00
when: newhost is defined and newhost
- name: populate monitor with map and keys
2023-09-01 15:42:19 -04:00
command: ceph-mon --cluster ceph --mkfs -i {{ ansible_hostname }} --monmap /etc/ceph/monmap --keyring /etc/ceph/ceph.mon.keyring
2023-09-01 15:42:19 -04:00
become_user: ceph
when: newhost is defined and newhost
- name: touch monitor and manager done files
2023-09-01 15:42:19 -04:00
file:
dest: /var/lib/ceph/{{ item }}/ceph-{{ ansible_hostname }}/done
2023-09-01 15:42:19 -04:00
state: touch
become_user: ceph
with_items:
- mon
- mgr
2023-09-01 15:42:19 -04:00
when: newhost is defined and newhost
2023-09-01 15:42:20 -04:00
- name: start monitor daemon
service:
name: "{{ item }}"
state: started
with_items:
- ceph-mon@{{ ansible_hostname }}
when: newhost is defined and newhost
2023-09-01 15:42:22 -04:00
- name: set msgr2 enabled
command: ceph mon enable-msgr2
run_once: yes
retries: 6
delay: 5
register: result
until: result.rc == 0
2023-09-01 15:42:22 -04:00
- name: set insecure_global_id_reclaim disabled
command: ceph config set mon auth_allow_insecure_global_id_reclaim false
run_once: yes
ignore_errors: yes
- name: set pg_autoscale_mode disabled
command: ceph config set global osd_pool_default_pg_autoscale_mode off
run_once: yes
ignore_errors: yes
- name: set Prometheus metric exporter enabled
command: ceph mgr module enable prometheus
run_once: yes
ignore_errors: yes
- name: enable Prometheus metrics on all pools
command: ceph config set mgr mgr/prometheus/rbd_stats_pools "*"
run_once: yes
ignore_errors: yes
- name: explicitly enable Prometheus performance counters
command: ceph config set mgr mgr/prometheus/exclude_perf_counters false
run_once: yes
ignore_errors: yes
when: debian_version|int >= 12
2023-09-01 15:42:20 -04:00
- name: create mgr auth keyring
command: ceph auth get-or-create mgr.{{ ansible_hostname }} mon 'allow profile mgr' osd 'allow *' mds 'allow *' --out-file /var/lib/ceph/mgr/ceph-{{ ansible_hostname }}/keyring
become_user: ceph
args:
creates: /var/lib/ceph/mgr/ceph-{{ ansible_hostname }}/keyring
2023-09-01 15:42:20 -04:00
- name: install OSD bootstrap keyring
file:
dest: /var/lib/ceph/bootstrap-osd/ceph.keyring
src: /etc/ceph/ceph.osd.bootstrap.keyring
state: link
- name: create mgr override systemd directory
file:
dest: /etc/systemd/system/ceph-mgr@.service.d
state: directory
- name: install mgr restart override systemd settings
template:
src: ceph/restart.conf.j2
dest: /etc/systemd/system/ceph-mgr@.service.d/restart.conf
register: systemd
- name: systemctl daemon-reload when files changed
command: systemctl daemon-reload
when: systemd.changed
- name: start but disable daemons
2023-09-01 15:42:19 -04:00
service:
name: "{{ item }}"
state: started
enabled: no
2023-09-01 15:42:19 -04:00
with_items:
- ceph-mon@{{ ansible_hostname }}
- ceph-mgr@{{ ansible_hostname }}
# Single-node cluster ruleset
- name: remove default CRUSH replicated_rule ruleset
command: ceph osd crush rule rm replicated_rule
2024-09-03 21:24:40 -04:00
when: pvc_nodes | length == 1
- name: add single-node CRUSH replicated_rule ruleset
command: ceph osd crush rule create-replicated replicated_rule default osd
2024-09-03 21:24:40 -04:00
when: pvc_nodes | length == 1
2023-09-01 15:42:19 -04:00
- meta: flush_handlers