diff --git a/CLAUDE.md b/CLAUDE.md new file mode 100644 index 0000000..fb9525e --- /dev/null +++ b/CLAUDE.md @@ -0,0 +1,88 @@ +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Overview + +This is **ceph-ansible** — Ansible playbooks, roles, and custom modules for deploying and managing Ceph clusters. The project is in maintenance mode; new deployments are encouraged to use `cephadm` instead. Supports Ceph releases from Dumpling (0.67) through Squid (19), with both containerized (Docker/Podman) and non-containerized deployment modes. + +## Common Commands + +### Linting +```bash +tox -e flake8 +``` +Max line length is 160 characters. Scans `./library`, `./module_utils/`, and `./tests/`. + +### Unit Tests +```bash +cd tests && py.test library/ module_utils/ +``` + +### Functional Tests (via Tox + Vagrant) +```bash +tox -e centos-container-all_daemons +tox -e ubuntu-non_container-all_daemons +tox -e rocky-container-lvm_osds +``` +Pattern: `{os}-{container|non_container}-{scenario}`. See `tox.ini` for all ~100+ environments. + +### RPM Building +```bash +make # builds SRPMs +make rpm # builds full RPMs +make clean +``` + +### After changing role defaults +```bash +./generate_group_vars_sample.sh +``` +The `group_vars/` sample files are version-controlled and must be regenerated when `roles/ceph-defaults/defaults/main.yml` changes. + +## Architecture + +### Playbook Entry Points +- `site.yml` — primary orchestration playbook; imports roles in dependency order for all daemon types (mons → osds → mgrs → clients → rgws → mdss → nfs → rbdmirrors → monitoring) +- `infrastructure-playbooks/` — operational playbooks run independently: `purge-cluster.yml`, `rolling_update.yml`, `shrink-*.yml`, `add-*.yml`, `cephadm-adopt.yml`, etc. + +### Role Dependency Chain +Most roles follow this pattern: +``` +ceph-defaults → ceph-facts → ceph-handler → ceph-validate → ceph-common → ceph-config → +``` +`ceph-defaults` is the canonical source for all configurable variables — check there before adding new variables. + +### Custom Modules (`library/`) +Python Ansible modules that wrap `ceph` CLI commands or the Ceph Python SDK: +- `ceph_key.py` — CephX authentication key management +- `ceph_pool.py` — pool create/modify/delete +- `ceph_crush.py` / `ceph_crush_rule.py` — CRUSH map management +- `ceph_ec_profile.py` — erasure coding profiles +- `ceph_fs.py` — CephFS filesystem management +- `ceph_config.py` — cluster config (`ceph config set/get`) +- `ceph_osd_flag.py` — OSD flags (noout, noscrub, etc.) +- `ceph_mgr_module.py` — mgr module enable/disable +- `ceph_volume.py` — OSD provisioning via `ceph-volume` +- `ceph_orch_apply.py` — cephadm orchestrator + +All modules share common container-execution utilities in `module_utils/ca_common.py`, which handles wrapping commands with `docker exec` or `podman exec` when running in containerized mode. + +### Filter Plugins (`plugins/filter/`) +- `dict2dict.py` — dict transformation +- `ipaddrs_in_ranges.py` — IP address filtering for network-aware config + +### Variable Precedence +1. `group_vars/all.yml.sample` — user-facing documented defaults (generated from role defaults) +2. `roles/ceph-defaults/defaults/main.yml` — authoritative defaults +3. Host/group vars in inventory — user overrides + +### Container vs. Non-Container +The boolean `containerized_deployment` variable (default: `false`) controls execution paths throughout roles and modules. When `true`, commands are prefixed with the container runtime and daemon container name. Both paths must be maintained in module code. + +## Key Conventions + +- **Commit format**: subject line (imperative mood) + blank line + body wrapped at 80 chars + `Signed-off-by:` line. Scope prefix encouraged (e.g., `ceph-osd: fix ...`). Reference issues with `Fixes: #XXXX`. +- **CI**: Jenkins runs on each PR. Add `[skip ci]` to PR title to bypass. Mergify handles merging (requires approval + CI pass). +- **Python style**: flake8, max 160 chars, no E501/W503. +- **Ansible collections required**: `ansible.utils`, `community.general`, `ansible.posix`, `openstack.ansible-config_template` — install with `ansible-galaxy collection install -r requirements.yml`. diff --git a/group_vars/all.yml b/group_vars/all.yml index 0cd5081..32e4d9f 100644 --- a/group_vars/all.yml +++ b/group_vars/all.yml @@ -155,7 +155,7 @@ ceph_repository: community # ceph_mirror: https://download.ceph.com ceph_stable_key: https://download.ceph.com/keys/release.asc -ceph_stable_release: squid +ceph_stable_release: 18.2.7 ceph_stable_repo: "{{ ceph_mirror }}/debian-{{ ceph_stable_release }}" #nfs_ganesha_stable: true # use stable repos for nfs-ganesha diff --git a/library/__pycache__/ceph_config.cpython-314.pyc b/library/__pycache__/ceph_config.cpython-314.pyc index e95c9d9..258d3ae 100644 Binary files a/library/__pycache__/ceph_config.cpython-314.pyc and b/library/__pycache__/ceph_config.cpython-314.pyc differ diff --git a/library/__pycache__/ceph_crush.cpython-314.pyc b/library/__pycache__/ceph_crush.cpython-314.pyc index deb381b..57c8153 100644 Binary files a/library/__pycache__/ceph_crush.cpython-314.pyc and b/library/__pycache__/ceph_crush.cpython-314.pyc differ diff --git a/library/__pycache__/ceph_crush_rule_info.cpython-314.pyc b/library/__pycache__/ceph_crush_rule_info.cpython-314.pyc index 1e4a41c..0310054 100644 Binary files a/library/__pycache__/ceph_crush_rule_info.cpython-314.pyc and b/library/__pycache__/ceph_crush_rule_info.cpython-314.pyc differ diff --git a/library/__pycache__/ceph_ec_profile.cpython-314.pyc b/library/__pycache__/ceph_ec_profile.cpython-314.pyc index 29fd087..1ebb660 100644 Binary files a/library/__pycache__/ceph_ec_profile.cpython-314.pyc and b/library/__pycache__/ceph_ec_profile.cpython-314.pyc differ diff --git a/library/__pycache__/ceph_key.cpython-314.pyc b/library/__pycache__/ceph_key.cpython-314.pyc index 687c027..c62de4c 100644 Binary files a/library/__pycache__/ceph_key.cpython-314.pyc and b/library/__pycache__/ceph_key.cpython-314.pyc differ diff --git a/library/__pycache__/ceph_key_info.cpython-314.pyc b/library/__pycache__/ceph_key_info.cpython-314.pyc index 9fb0b81..f1e032c 100644 Binary files a/library/__pycache__/ceph_key_info.cpython-314.pyc and b/library/__pycache__/ceph_key_info.cpython-314.pyc differ diff --git a/library/__pycache__/ceph_mgr_module.cpython-314.pyc b/library/__pycache__/ceph_mgr_module.cpython-314.pyc index 52026a9..0c4b605 100644 Binary files a/library/__pycache__/ceph_mgr_module.cpython-314.pyc and b/library/__pycache__/ceph_mgr_module.cpython-314.pyc differ diff --git a/library/__pycache__/ceph_osd_flag.cpython-314.pyc b/library/__pycache__/ceph_osd_flag.cpython-314.pyc index dda3e2d..f233e6a 100644 Binary files a/library/__pycache__/ceph_osd_flag.cpython-314.pyc and b/library/__pycache__/ceph_osd_flag.cpython-314.pyc differ diff --git a/library/__pycache__/ceph_pool.cpython-314.pyc b/library/__pycache__/ceph_pool.cpython-314.pyc index ab31b93..8d27eda 100644 Binary files a/library/__pycache__/ceph_pool.cpython-314.pyc and b/library/__pycache__/ceph_pool.cpython-314.pyc differ diff --git a/library/__pycache__/ceph_volume.cpython-314.pyc b/library/__pycache__/ceph_volume.cpython-314.pyc index 1cf4462..f49970c 100644 Binary files a/library/__pycache__/ceph_volume.cpython-314.pyc and b/library/__pycache__/ceph_volume.cpython-314.pyc differ diff --git a/library/__pycache__/radosgw_user.cpython-314.pyc b/library/__pycache__/radosgw_user.cpython-314.pyc index 9b25585..5643846 100644 Binary files a/library/__pycache__/radosgw_user.cpython-314.pyc and b/library/__pycache__/radosgw_user.cpython-314.pyc differ diff --git a/plugins/filter/__pycache__/dict2dict.cpython-314.pyc b/plugins/filter/__pycache__/dict2dict.cpython-314.pyc index c5fe229..c97bfaf 100644 Binary files a/plugins/filter/__pycache__/dict2dict.cpython-314.pyc and b/plugins/filter/__pycache__/dict2dict.cpython-314.pyc differ diff --git a/plugins/filter/__pycache__/ipaddrs_in_ranges.cpython-314.pyc b/plugins/filter/__pycache__/ipaddrs_in_ranges.cpython-314.pyc index d56e8ab..00cf8fe 100644 Binary files a/plugins/filter/__pycache__/ipaddrs_in_ranges.cpython-314.pyc and b/plugins/filter/__pycache__/ipaddrs_in_ranges.cpython-314.pyc differ diff --git a/roles/ceph-defaults/defaults/main.yml b/roles/ceph-defaults/defaults/main.yml index 938ef52..528ea0a 100644 --- a/roles/ceph-defaults/defaults/main.yml +++ b/roles/ceph-defaults/defaults/main.yml @@ -147,7 +147,7 @@ valid_ceph_repository: # ceph_mirror: https://download.ceph.com ceph_stable_key: https://download.ceph.com/keys/release.asc -ceph_stable_release: squid +ceph_stable_release: reef ceph_stable_repo: "{{ ceph_mirror }}/debian-{{ ceph_stable_release }}" nfs_ganesha_stable: true # use stable repos for nfs-ganesha diff --git a/vagrant.yaml b/vagrant.yaml index f8a9807..857c15f 100644 --- a/vagrant.yaml +++ b/vagrant.yaml @@ -1,17 +1,17 @@ all: hosts: ceph1: - ansible_host: 192.168.1.59 + ansible_host: 192.168.1.52 ansible_user: foo ansible_password: qweqwe become_password: qweqwe ceph2: - ansible_host: 192.168.1.152 + ansible_host: 192.168.1.91 ansible_user: foo ansible_password: qweqwe become_password: qweqwe ceph3: - ansible_host: 192.168.1.96 + ansible_host: 192.168.1.136 ansible_user: foo ansible_password: qweqwe become_password: qweqwe @@ -22,8 +22,6 @@ all: mons: hosts: ceph1: - ceph2: - ceph3: osds: hosts: ceph1: