|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +Foremanctl is a Foreman and Katello deployment tool using Podman quadlets and Ansible. It supports Foreman 3.16, Katello 4.18, Pulp 3.73, and Candlepin 4.6, targeting ansible-core 2.14 as present in CentOS Stream 9. |
| 8 | + |
| 9 | +## Development Environment Setup |
| 10 | + |
| 11 | +Initialize the development environment: |
| 12 | +```bash |
| 13 | +./setup-environment |
| 14 | +source .venv/bin/activate |
| 15 | +``` |
| 16 | + |
| 17 | +This creates a Python virtual environment and installs dependencies from `src/requirements.txt` and `development/requirements.txt`, then builds Ansible collections for both production (`foremanctl`) and development (`forge`) use. |
| 18 | + |
| 19 | +## Core Architecture |
| 20 | + |
| 21 | +### CLI Tools |
| 22 | +- `./foremanctl` - Production deployment tool using obsah with production Ansible collections |
| 23 | +- `./forge` - Development/testing tool using obsah with development Ansible collections |
| 24 | + |
| 25 | +Both tools are bash wrappers around the `obsah` CLI tool that set environment variables: |
| 26 | +- `OBSAH_NAME` - Tool identifier |
| 27 | +- `OBSAH_DATA` - Ansible data directory (`src` for foremanctl, `development` for forge) |
| 28 | +- `OBSAH_INVENTORY` - Ansible inventory path |
| 29 | +- `OBSAH_STATE` - State persistence directory |
| 30 | +- `ANSIBLE_COLLECTIONS_PATH` - Path to built collections |
| 31 | + |
| 32 | +### Directory Structure |
| 33 | +- `src/` - Production Ansible roles, playbooks, and configurations |
| 34 | +- `development/` - Development-specific Ansible configurations |
| 35 | +- `tests/` - pytest-based test suite with testinfra integration |
| 36 | +- `inventories/` - Ansible inventory configurations |
| 37 | +- `build/collections/` - Built Ansible collections (generated) |
| 38 | + |
| 39 | +### Ansible Roles |
| 40 | +Key roles in `src/roles/`: |
| 41 | +- `certificates` - Certificate management and issuance |
| 42 | +- `foreman` - Foreman application deployment |
| 43 | +- `candlepin` - Candlepin subscription management |
| 44 | +- `pulp` - Pulp content management |
| 45 | +- `postgresql` - Database setup |
| 46 | +- `httpd` - Web server configuration |
| 47 | +- `redis` - Redis cache configuration |
| 48 | +- `hammer` - Hammer CLI setup |
| 49 | + |
| 50 | +## Common Development Tasks |
| 51 | + |
| 52 | +### VM-based Development and Testing |
| 53 | +```bash |
| 54 | +# Start development environment |
| 55 | +./forge vms start |
| 56 | + |
| 57 | +# Deploy Foreman with default settings |
| 58 | +./foremanctl deploy --foreman-initial-admin-password=changeme |
| 59 | + |
| 60 | +# Setup hammer CLI (optional) |
| 61 | +./forge setup-repositories |
| 62 | +./foremanctl setup-hammer |
| 63 | + |
| 64 | +# Run all tests |
| 65 | +./forge test |
| 66 | + |
| 67 | +# Stop environment |
| 68 | +./forge vms stop |
| 69 | +``` |
| 70 | + |
| 71 | +### Building and Collections |
| 72 | +```bash |
| 73 | +# Build production collections |
| 74 | +make build/collections/foremanctl |
| 75 | + |
| 76 | +# Build development collections |
| 77 | +make build/collections/forge |
| 78 | + |
| 79 | +# Create distribution tarball |
| 80 | +make dist |
| 81 | +``` |
| 82 | + |
| 83 | +### Testing |
| 84 | +Tests use pytest with testinfra for infrastructure testing and apypie for Foreman API testing. Test configuration is in `tests/conftest.py` with fixtures for: |
| 85 | +- Server and client connection via Vagrant SSH |
| 86 | +- Foreman API client with authentication |
| 87 | +- Certificate management (default vs installer certificates) |
| 88 | +- Katello entities (organizations, products, repositories, content views, etc.) |
| 89 | + |
| 90 | +Run individual test files: |
| 91 | +```bash |
| 92 | +# Run specific test module |
| 93 | +pytest tests/foreman_test.py |
| 94 | + |
| 95 | +# Run with specific certificate source |
| 96 | +pytest --certificate-source=installer tests/ |
| 97 | +``` |
| 98 | + |
| 99 | +## Configuration Management |
| 100 | + |
| 101 | +### Service Configuration |
| 102 | +Services use Podman secrets for configuration files, following naming conventions: |
| 103 | +- Config files: `<role_namespace>-<filename>-<extension>` |
| 104 | +- Strings: `<role_namespace>-<descriptive_name>` |
| 105 | +- With app context: `<role_namespace>-<app>-<filename>-<extension>` |
| 106 | + |
| 107 | +View configurations: |
| 108 | +```bash |
| 109 | +# List all secrets |
| 110 | +podman secret ls |
| 111 | + |
| 112 | +# View specific secret |
| 113 | +podman secret inspect --showsecret --format "{{.SecretData}}" <secret-name> |
| 114 | +``` |
| 115 | + |
| 116 | +### Ansible Collections |
| 117 | +Production requirements in `src/requirements.yml`: |
| 118 | +- `community.postgresql` - PostgreSQL management |
| 119 | +- `community.crypto` - Certificate management |
| 120 | +- `ansible.posix` - POSIX utilities |
| 121 | +- `containers.podman` - Podman container management |
| 122 | +- `theforeman.foreman` - Foreman-specific modules |
| 123 | + |
| 124 | +Development requirements in `development/requirements.yml` include additional collections for testing and VM management. |
| 125 | + |
| 126 | +## Package Management |
| 127 | + |
| 128 | +RPM packages available via COPR: |
| 129 | +```bash |
| 130 | +dnf copr enable @theforeman/foremanctl rhel-9-x86_64 |
| 131 | +dnf install foremanctl |
| 132 | +``` |
| 133 | + |
| 134 | +## Important Notes |
| 135 | + |
| 136 | +- Uses Vagrant with libvirt provider for VM-based development |
| 137 | +- All Ansible configuration managed through obsah CLI wrapper |
| 138 | +- State persistence handled automatically via `OBSAH_STATE` directory |
| 139 | +- Test fixtures create temporary Katello entities that are cleaned up automatically |
| 140 | +- Certificate management supports both default and installer-provided certificates |
0 commit comments