Ansible playbook for automating Ceph cluster deployment via cephadm, with optional Ceph-CSI integration for Kubernetes.
- Variable Validation: Validates all necessary variables before deployment
- Dynamic Repository Configuration: Supports RHCS, community, IBM, Shaman (dev), and custom repositories
- OS Compatibility: RHEL/CentOS and Ubuntu support
- Container Engine Setup: Automatic podman/docker configuration
- Ceph-CSI Integration: Includes templates for Kubernetes CSI driver setup
├── playbooks/
│ ├── site.yml # Main deployment playbook
│ └── reset.yml # Cluster cleanup playbook
├── roles/
│ ├── ceph-common/ # Environment prep, package installation
│ ├── ceph-deploy/ # Cluster bootstrap and expansion
│ └── ceph-cleanup/ # Tear-down and removal
├── library/ # Custom Ansible modules
├── module_utils/ # Shared Python utilities
├── ceph_defaults/ # Default variables role
├── group_vars/ # Group variables
├── validate/ # Variable validation tasks
├── ceph-csi-test/ # Kubernetes Ceph-CSI test resources
├── inventory.ini # Template inventory
└── ansible.cfg # Ansible configuration
- SSH access to all target nodes
- Python 3.10+
# Generate SSH keys (if needed)
ssh-keygen
# Copy SSH key to target nodes
ssh-copy-id your_user@server_ip
# Update /etc/hosts
echo "server_ip your_hostname" | sudo tee -a /etc/hosts# Ubuntu 22.04
sudo apt-get -y update
sudo apt install -y python3 python3-venv python3-pip git
# Ubuntu 20.04
sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt-get -y update
sudo apt install -y python3.10 python3-pip git python3.10-venv
# RHEL/CentOS 8+
dnf install tar curl gcc openssl-devel bzip2-devel libffi-devel zlib-devel wget make git -ygit clone https://github.com/somaz94/install-cephadm-ansible.git
VENVDIR=cephadm-venv
CEPHADMDIR=install-cephadm-ansible
python3 -m venv $VENVDIR
source $VENVDIR/bin/activate
cd $CEPHADMDIR
pip install -U -r requirements.txtEdit inventory.ini and group_vars/all.yml for your cluster configuration.
ansible --version
ansible all -i inventory.ini -m ping# Full deployment
ansible-playbook -i inventory.ini playbooks/site.yml
# Selective role execution
ansible-playbook -i inventory.ini playbooks/site.yml -e "run_ceph_common=true run_ceph_deploy=false"
ansible-playbook -i inventory.ini playbooks/site.yml -e "run_ceph_common=false run_ceph_deploy=true"
# Use RHCS repository
ansible-playbook -i inventory.ini playbooks/site.yml --extra-vars "ceph_origin=rhcs"
# Cleanup cluster
ansible-playbook -i inventory.ini playbooks/reset.ymlceph orch host ls
ceph -s
ceph osd tree
ceph orch ls --service-type mon
ceph orch ls --service-type mgr
ceph orch ls --service-type osd
ceph dfNote: Ensure your Kubernetes cluster is fully operational before installing the Ceph cluster.
# Create pool
ceph osd pool create kube 128
# Modify pool replica (optional)
ceph osd pool get <pool-name> size
ceph osd pool set <pool-name> size 2helm repo add ceph-csi https://ceph.github.io/csi-charts
helm repo update
# For RBD
helm install ceph-csi-rbd ceph-csi/ceph-csi-rbd \
--namespace ceph-csi --create-namespace \
--version <chart_version>
# For CephFS
helm install ceph-csi-cephfs ceph-csi/ceph-csi-cephfs \
--namespace ceph-csi --create-namespace \
--version <chart_version># Get cluster FSID
ceph fsid
# Check monitor port
ss -nlpt | grep 6789
# Get auth key
ceph auth list | grep client.admin -A5kubectl apply -f ceph-csi-test/ceph-csi-values.yaml
kubectl apply -f ceph-csi-test/ceph-csi-storageclass.yaml
kubectl apply -f ceph-csi-test/test-pod.yamlThis project is licensed under the MIT License - see the LICENSE file for details.