Skip to content

Commit e14101d

Browse files
pablofontanillaclaude
authored andcommitted
feat: add 'make doctor' configuration preflight
Read-only preflight that validates the full deployment configuration and prints a concrete fix command for every failure: required tools, SSH key, Ansible collections, inventory.ini, instance.env plus live AWS credentials, dev-scripts topology configs and pull secret, CI registry auth cross-check with live CI token check, and the kcli pull secret. Exits non-zero if and only if a check failed. - 'make doctor' runs common checks plus every auto-detected section - 'make doctor <cluster-type>' validates strictly for that deployment: the method's section becomes mandatory and its method-specific warnings are promoted to failures; cluster-type goals following 'doctor' are neutralized so they never trigger a deployment - inventory.ini stays informational when absent (the AWS flow generates it via 'make inventory'), but a present-but-unedited copy of the sample fails, since that breaks deployment in confusing ways - deploy-cluster.sh preflight error paths now point at 'make doctor' Checks are ported from the validation steps in .claude/commands/setup.md and the in-playbook preflight in roles/dev-scripts/install-dev/tasks/config.yml. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LSBffYjh3rtLToAMR1pjQT
1 parent 0a43cbf commit e14101d

6 files changed

Lines changed: 421 additions & 0 deletions

File tree

CLAUDE.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ make patch-nodes # Build resource-agents RPM and patch cluster nodes
3838
make ssh # SSH into EC2 instance
3939
make info # Display instance information
4040
make inventory # Update inventory.ini with current instance IP
41+
make doctor # Validate configuration and prerequisites (read-only)
42+
make doctor <type> # Validate strictly for a specific cluster type (e.g. fencing-kcli)
4143
```
4244

4345
### Ansible Deployment Methods

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ If you're using [Claude Code](https://claude.ai/code), use the `/setup` command
7979
- Validating your setup
8080

8181
Run `/setup` to begin, or `/setup <method>` to configure a specific deployment method (aws, external, kcli, dev-scripts).
82+
83+
If you are not using Claude Code, or want a quick non-interactive check, run `make doctor` from the `deploy/` directory. It validates required tools, SSH keys, Ansible collections, and configuration files, printing a fix command for every problem found. `make doctor <cluster-type>` (for example `make doctor arbiter-ipi`) validates strictly for one deployment type.
8284
## Helpers
8385

8486
The [helpers/](helpers/) directory contains utilities for cluster operations including resource-agents patching, fencing validation, and containerized build validation. To quickly verify a resource-agents branch compiles on CentOS Stream 9 and 10:

deploy/Makefile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,20 @@ ifeq (deploy,$(firstword $(MAKECMDGOALS)))
1313
endif
1414
endif
1515

16+
# Handle 'make doctor <cluster-type>' pattern
17+
# When 'doctor' is first, following cluster types select strict validation for
18+
# that deployment; the cluster-type goals themselves are neutralized below so
19+
# they don't trigger an actual deployment.
20+
ifeq (doctor,$(firstword $(MAKECMDGOALS)))
21+
DOCTOR_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
22+
ifneq ($(DOCTOR_ARGS),)
23+
DOCTOR_INVALID_ARGS := $(filter-out $(VALID_CLUSTER_TYPES),$(DOCTOR_ARGS))
24+
ifneq ($(DOCTOR_INVALID_ARGS),)
25+
$(error Unknown cluster type: '$(DOCTOR_INVALID_ARGS)'. Run 'make help' for more information.)
26+
endif
27+
endif
28+
endif
29+
1630
create:
1731
@./aws-hypervisor/scripts/create.sh
1832

@@ -64,6 +78,14 @@ inventory:
6478
sync-config:
6579
@bash -c 'set -e; source ./common.sh; if [ "$${CONFIG_SYNCED_COUNT:-0}" -eq 0 ]; then echo "Config files: everything up to date."; fi'
6680

81+
doctor:
82+
@./openshift-clusters/scripts/doctor.sh $(DOCTOR_ARGS)
83+
84+
ifeq (doctor,$(firstword $(MAKECMDGOALS)))
85+
# Cluster types after 'doctor' are arguments to doctor.sh, not deployments
86+
$(VALID_CLUSTER_TYPES):
87+
@:
88+
else
6789
fencing-ipi:
6890
@./openshift-clusters/scripts/deploy-cluster.sh --topology fencing --method ipi
6991

@@ -91,6 +113,7 @@ fencing-kcli:
91113
fencing-assisted:
92114
@$(MAKE) fencing-ipi
93115
@./openshift-clusters/scripts/deploy-fencing-assisted.sh
116+
endif
94117

95118
keep-instance:
96119
@../helpers/keep-instance.sh '$(DAYS)'
@@ -130,6 +153,8 @@ help:
130153
@echo " ssh - SSH into the EC2 instance"
131154
@echo " info - Display instance information"
132155
@echo " inventory - Update inventory.ini with current instance IP"
156+
@echo " doctor - Validate configuration and prerequisites (read-only)"
157+
@echo " doctor <cluster-type>- Validate strictly for a specific cluster type"
133158
@echo " keep-instance - Tag instance with keep-N retention (default: 2, max: 5)"
134159
@echo " Usage: make keep-instance or make keep-instance DAYS=5"
135160
@echo " sync-config - Sync files from config/ to their canonical locations"

deploy/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ Additionally, if you're using Mac OS, you might not have `timeout`, so you might
4040

4141
## Configuration
4242

43+
Run `make doctor` at any time to validate your setup before deploying. It is a read-only preflight that checks required tools, SSH keys, Ansible collections, and every configuration file, and prints a concrete fix command for each problem it finds. Use `make doctor <cluster-type>` (for example `make doctor fencing-kcli`) to validate strictly for a specific deployment type: the checks specific to that deployment method become mandatory.
44+
4345
Before deployment, configure your environment by creating an `instance.env` file in the central [config/](../config/) folder. Copy `config/instance.env.template` to `config/instance.env` and set all variables to valid values for your user. Every `make` target syncs `config/` files to the locations the scripts read them from (`aws-hypervisor/instance.env` in this case); run `make sync-config` to sync explicitly. Editing `aws-hypervisor/instance.env` directly still works as before. See [config/README.md](../config/README.md) for all available configuration files.
4446

4547
## Available Commands

deploy/openshift-clusters/scripts/deploy-cluster.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ fi
7373
# Check if instance data exists
7474
if [[ ! -f "$(get_node_dir)/aws-instance-id" ]]; then
7575
echo "Error: No instance found. Please run 'make deploy' first."
76+
echo "Run 'make doctor' to check your setup."
7677
exit 1
7778
fi
7879

@@ -81,6 +82,7 @@ if [[ ! -f "${DEPLOY_DIR}/openshift-clusters/inventory.ini" ]]; then
8182
echo "Error: inventory.ini not found in ${DEPLOY_DIR}/openshift-clusters/"
8283
echo "Please ensure the inventory file is properly configured."
8384
echo "You can run 'make inventory' to update it with current instance information."
85+
echo "Run 'make doctor' to check your setup."
8486
exit 1
8587
fi
8688

0 commit comments

Comments
 (0)