Skip to content

Commit f152d1e

Browse files
fonta-rhclaude
andcommitted
feat: add central config/ folder with sync-to-canonical
Add a single config/ folder at the repository root where users create their configuration files. Every make-accessible script syncs config/ files to their canonical locations (newer-wins, never deletes) before doing anything else; the playbooks and roles keep reading from the canonical locations unchanged. - Move all templates and example configs into config/ (single source): instance.env.template, config_*_example.sh, kcli.yml.template, assisted.yml.template, plus a README map and a .gitignore that prevents real config files (including the pull secret) from ever being committed - Add sync_config_files() to aws-hypervisor/scripts/common.sh with a manifest of src:dest[:dest2] entries; the pull secret fans out to both the dev-scripts and kcli role locations - Restructure common.sh so the sync runs before instance.env is sourced, and replace the raw missing-file source error with an actionable hint - Add 'make sync-config' for users who invoke ansible-playbook directly, and register init-host.yml.local in the manifest (it is consumed by init-host.yml) - Source common.sh from get-tnf-logs.sh and helpers/keep-instance.sh so every make target inherits the sync - Gitignore vars/assisted.yml (contains credentials, was not ignored) - Update all docs and the /setup command to point at config/, keeping a note that editing canonical locations directly still works Backwards compatible: config/ ships with templates only, so the sync is a no-op until the user explicitly creates a file there. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Mk1uuxv3YkApKm8w55Kxjd
1 parent b40957d commit f152d1e

26 files changed

Lines changed: 218 additions & 106 deletions

.claude/commands/setup.md

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ All deployment methods require an SSH key on the local machine. Check for any of
3737

3838
If no SSH key exists, create one with: `ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519`
3939

40-
**Note for non-default key paths:** Set `SSH_PUBLIC_KEY` in [deploy/aws-hypervisor/instance.env](deploy/aws-hypervisor/instance.env). This is used by both the AWS hypervisor and dev-scripts deployments.
40+
**Note for non-default key paths:** Set `SSH_PUBLIC_KEY` in [config/instance.env](config/instance.env). This is used by both the AWS hypervisor and dev-scripts deployments.
4141

4242
### Inventory File
4343

@@ -60,22 +60,19 @@ Required for: external, kcli, dev-scripts
6060

6161
Required for: kcli, dev-scripts
6262

63-
The same pull secret is used by both kcli and dev-scripts (stored in different locations).
64-
65-
- kcli location: [deploy/openshift-clusters/roles/kcli/kcli-install/files/pull-secret.json](deploy/openshift-clusters/roles/kcli/kcli-install/files/pull-secret.json)
66-
- dev-scripts location: [deploy/openshift-clusters/roles/dev-scripts/install-dev/files/pull-secret.json](deploy/openshift-clusters/roles/dev-scripts/install-dev/files/pull-secret.json)
63+
The same pull secret is used by both kcli and dev-scripts. Create it once in the central config folder: [config/pull-secret.json](config/pull-secret.json). The sync (run by every `make` target, or explicitly via `cd deploy && make sync-config`) distributes it to both role locations automatically.
6764

6865
**Setup logic:**
69-
- Check if file exists in either location
70-
- If it exists in one location, offer to copy it to the other
66+
- Check if [config/pull-secret.json](config/pull-secret.json) exists
67+
- If not, check the canonical locations (`deploy/openshift-clusters/roles/dev-scripts/install-dev/files/pull-secret.json` and `deploy/openshift-clusters/roles/kcli/kcli-install/files/pull-secret.json`) - a file there means the user configured it the direct-edit way, which is still valid
7168
- If it doesn't exist anywhere:
7269
- User gets pull secret from: https://cloud.redhat.com/openshift/install/pull-secret
7370
- **For CI builds**: Must include `registry.ci.openshift.org` access (see [CI Token](#ci-token) below)
74-
- Suggest creating file and pasting content
71+
- Suggest creating [config/pull-secret.json](config/pull-secret.json) and pasting content
7572

7673
**Validation:**
77-
- Validate pull secret is valid JSON: `jq . < <path-to-pull-secret>`
78-
- Check for CI registry access (if needed): `jq '.auths | has("registry.ci.openshift.org")' < <path-to-pull-secret>`
74+
- Validate pull secret is valid JSON: `jq . < config/pull-secret.json`
75+
- Check for CI registry access (if needed): `jq '.auths | has("registry.ci.openshift.org")' < config/pull-secret.json`
7976

8077
### CI Token
8178

@@ -107,10 +104,11 @@ Required for: dev-scripts (when using CI builds)
107104
- `export RHSM_ORG="your-org-id"`
108105
- Guide: https://access.redhat.com/solutions/3341191
109106

110-
- **Option B**: Local config file [vars/init-host.yml.local](vars/init-host.yml.local)
111-
- Template: [vars/init-host.yml.sample](vars/init-host.yml.sample)
112-
- Check if exists
113-
- Suggest copying: `cp vars/init-host.yml.sample vars/init-host.yml.local`
107+
- **Option B**: Local config file [config/init-host.yml.local](config/init-host.yml.local)
108+
- Base file: [deploy/openshift-clusters/vars/init-host.yml](deploy/openshift-clusters/vars/init-host.yml)
109+
- Check if exists (also accept the direct-edit location `deploy/openshift-clusters/vars/init-host.yml.local`)
110+
- Suggest copying: `cp deploy/openshift-clusters/vars/init-host.yml config/init-host.yml.local`
111+
- The sync distributes it to `deploy/openshift-clusters/vars/init-host.yml.local`; suggest `cd deploy && make sync-config` before running the playbook directly
114112

115113
- **Option C**: Command line (they'll add when running playbook)
116114

@@ -135,17 +133,18 @@ Required for: dev-scripts (when using CI builds)
135133

136134
**Files to configure:**
137135

138-
1. **Instance environment**: [deploy/aws-hypervisor/instance.env](deploy/aws-hypervisor/instance.env)
139-
- Template: [deploy/aws-hypervisor/instance.env.template](deploy/aws-hypervisor/instance.env.template)
140-
- Check if it exists
136+
1. **Instance environment**: [config/instance.env](config/instance.env)
137+
- Template: [config/instance.env.template](config/instance.env.template)
138+
- Check if it exists (also accept the direct-edit location [deploy/aws-hypervisor/instance.env](deploy/aws-hypervisor/instance.env))
141139
- User must edit ALL variables with their specific values
142140
- Optional: Set `RHSM_ACTIVATION_KEY` and `RHSM_ORG` for hands-off deployment
143141
- Guide: https://access.redhat.com/solutions/3341191
144-
- Suggest copying: `cp deploy/aws-hypervisor/instance.env.template deploy/aws-hypervisor/instance.env`
142+
- Suggest copying: `cp config/instance.env.template config/instance.env`
143+
- Every `make` target syncs it to `deploy/aws-hypervisor/instance.env` where the scripts read it
145144

146145
**Validation:**
147-
- Verify [deploy/aws-hypervisor/instance.env](deploy/aws-hypervisor/instance.env) exists
148-
- Test by sourcing: `source deploy/aws-hypervisor/instance.env` (should not error)
146+
- Verify [config/instance.env](config/instance.env) (or `deploy/aws-hypervisor/instance.env`) exists
147+
- Test by sourcing: `source config/instance.env` (should not error)
149148

150149
**Next steps:**
151150
- Quick deploy: `cd deploy && make deploy arbiter-ipi`
@@ -165,11 +164,12 @@ Required for: dev-scripts (when using CI builds)
165164

166165
**Files to configure:**
167166

168-
1. **Optional persistent config**: [deploy/openshift-clusters/vars/kcli.yml](deploy/openshift-clusters/vars/kcli.yml)
169-
- Template: [deploy/openshift-clusters/vars/kcli.yml.template](deploy/openshift-clusters/vars/kcli.yml.template)
170-
- Check if exists
167+
1. **Optional persistent config**: [config/kcli.yml](config/kcli.yml)
168+
- Template: [config/kcli.yml.template](config/kcli.yml.template)
169+
- Check if exists (also accept the direct-edit location [deploy/openshift-clusters/vars/kcli.yml](deploy/openshift-clusters/vars/kcli.yml))
171170
- For setting preferred defaults (cluster name, resources, etc.)
172-
- Suggest copying: `cp deploy/openshift-clusters/vars/kcli.yml.template deploy/openshift-clusters/vars/kcli.yml`
171+
- Suggest copying: `cp config/kcli.yml.template config/kcli.yml`
172+
- The sync distributes it to `deploy/openshift-clusters/vars/kcli.yml`; suggest `cd deploy && make sync-config` before running the playbook directly
173173

174174
**Validation:**
175175
- Verify inventory file exists
@@ -192,28 +192,29 @@ Required for: dev-scripts (when using CI builds)
192192

193193
**Files to configure:**
194194

195-
1. **Topology config files** in [deploy/openshift-clusters/roles/dev-scripts/install-dev/files/](deploy/openshift-clusters/roles/dev-scripts/install-dev/files/):
195+
1. **Topology config files** in [config/](config/):
196196

197-
a. **Arbiter config**: [config_arbiter.sh](deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_arbiter.sh)
198-
- Template: [config_arbiter_example.sh](deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_arbiter_example.sh)
199-
- Check if exists
197+
a. **Arbiter config**: [config/config_arbiter.sh](config/config_arbiter.sh)
198+
- Template: [config/config_arbiter_example.sh](config/config_arbiter_example.sh)
199+
- Check if exists (also accept the direct-edit location `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_arbiter.sh`)
200200
- User must set:
201201
- `OPENSHIFT_RELEASE_IMAGE` (e.g., `quay.io/openshift-release-dev/ocp-release:4.19.0-rc.5-multi-x86_64`)
202202
- `CI_TOKEN` (see [CI Token](#ci-token)) unless using `OPENSHIFT_CI="True"`
203-
- Suggest copying: `cp deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_arbiter_example.sh deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_arbiter.sh`
203+
- Suggest copying: `cp config/config_arbiter_example.sh config/config_arbiter.sh`
204204

205-
b. **Fencing config**: [config_fencing.sh](deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_fencing.sh)
206-
- Template: [config_fencing_example.sh](deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_fencing_example.sh)
207-
- Check if exists
205+
b. **Fencing config**: [config/config_fencing.sh](config/config_fencing.sh)
206+
- Template: [config/config_fencing_example.sh](config/config_fencing_example.sh)
207+
- Check if exists (also accept the direct-edit location `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_fencing.sh`)
208208
- Same requirements as arbiter config
209-
- Suggest copying: `cp deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_fencing_example.sh deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_fencing.sh`
209+
- Suggest copying: `cp config/config_fencing_example.sh config/config_fencing.sh`
210210

211+
- The sync distributes these to `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/`; suggest `cd deploy && make sync-config` before running the playbook directly
211212
- **Config reference**: https://github.com/openshift-metal3/dev-scripts/blob/master/config_example.sh
212213

213214
**Validation:**
214215
- Verify inventory file exists
215-
- For arbiter: Check [config_arbiter.sh](deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_arbiter.sh) exists
216-
- For fencing: Check [config_fencing.sh](deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_fencing.sh) exists
216+
- For arbiter: Check [config/config_arbiter.sh](config/config_arbiter.sh) (or the direct-edit location) exists
217+
- For fencing: Check [config/config_fencing.sh](config/config_fencing.sh) (or the direct-edit location) exists
217218
- Verify pull secret exists and is valid JSON
218219

219220
**Next steps:**

.claude/commands/setup/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Configures deployment to your own RHEL 9 server (non-AWS).
4040
Configures automated RHEL hypervisor deployment in AWS EC2.
4141

4242
**Files configured:**
43-
- `deploy/aws-hypervisor/instance.env` - AWS instance configuration
43+
- `config/instance.env` - AWS instance configuration (synced to `deploy/aws-hypervisor/instance.env`)
4444

4545
**Use when:** You want to deploy a hypervisor in AWS
4646

@@ -49,8 +49,8 @@ Configures kcli-based OpenShift deployment (fencing topology).
4949

5050
**Files configured:**
5151
- `deploy/openshift-clusters/inventory.ini` - Target host details
52-
- `deploy/openshift-clusters/roles/kcli/kcli-install/files/pull-secret.json` - OpenShift pull secret
53-
- `deploy/openshift-clusters/vars/kcli.yml` (optional) - Persistent kcli preferences
52+
- `config/pull-secret.json` - OpenShift pull secret (synced to the kcli role files directory)
53+
- `config/kcli.yml` (optional) - Persistent kcli preferences (synced to `deploy/openshift-clusters/vars/kcli.yml`)
5454
- SSH key validation
5555

5656
**Use when:** You want to deploy using the modern kcli method
@@ -60,9 +60,9 @@ Configures traditional dev-scripts deployment (arbiter or fencing topology).
6060

6161
**Files configured:**
6262
- `deploy/openshift-clusters/inventory.ini` - Target host details
63-
- `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_arbiter.sh` - Arbiter config
64-
- `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_fencing.sh` - Fencing config
65-
- `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/pull-secret.json` - OpenShift pull secret
63+
- `config/config_arbiter.sh` - Arbiter config (synced to the dev-scripts role files directory)
64+
- `config/config_fencing.sh` - Fencing config (synced to the dev-scripts role files directory)
65+
- `config/pull-secret.json` - OpenShift pull secret (synced to both the dev-scripts and kcli role files directories)
6666
- Ansible collections installation
6767
- SSH key validation
6868

CLAUDE.md

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ ansible-playbook kcli-install.yml -i inventory.ini -e "force_cleanup=true"
7272

7373
#### Assisted Installer Method (Spoke TNF via ACM)
7474
```bash
75-
# Copy and customize the configuration template
76-
cp vars/assisted.yml.template vars/assisted.yml
75+
# Copy and customize the configuration template (from the repository root)
76+
cp config/assisted.yml.template config/assisted.yml
7777

7878
# Deploy hub + spoke TNF cluster via assisted installer
7979
make deploy fencing-assisted
@@ -130,20 +130,30 @@ make ansible-lint
130130

131131
### Key Configuration Files
132132

133-
#### Dev-scripts Method
134-
- `inventory.ini`: Ansible inventory (copy from `inventory.ini.sample`)
133+
#### Central config/ Folder
134+
User configuration files are created in `config/` at the repository root (templates and examples live there; see `config/README.md`). Every make-accessible script syncs `config/` files to the canonical locations below before doing anything else (newer-wins, never deletes); `make sync-config` runs the sync explicitly. Editing the canonical locations directly still works: a `config/` file only becomes authoritative once the user creates it.
135+
136+
- `config/instance.env`: AWS hypervisor settings (copy from `config/instance.env.template`)
137+
- `config/pull-secret.json`: OpenShift pull secret, fanned out to both dev-scripts and kcli role locations
138+
- `config/config_arbiter.sh`, `config/config_fencing.sh`, `config/config_sno.sh`: dev-scripts topology configs (copy from the `config/config_*_example.sh` files)
139+
- `config/kcli.yml`: kcli variable overrides (copy from `config/kcli.yml.template`)
140+
- `config/assisted.yml`: assisted installer variables (copy from `config/assisted.yml.template`)
141+
- `config/init-host.yml.local`: external-host RHSM overrides (copy from `deploy/openshift-clusters/vars/init-host.yml`)
142+
143+
#### Dev-scripts Method (canonical locations)
144+
- `inventory.ini`: Ansible inventory (copy from `inventory.ini.sample`; generated by `make inventory` on AWS)
135145
- `roles/dev-scripts/install-dev/files/config_arbiter.sh`: Arbiter topology config
136146
- `roles/dev-scripts/install-dev/files/config_fencing.sh`: Fencing topology config
137147
- `roles/dev-scripts/install-dev/files/config_sno.sh`: Single Node OpenShift config
138148
- `roles/dev-scripts/install-dev/files/pull-secret.json`: OpenShift pull secret
139149

140-
#### Kcli Method
150+
#### Kcli Method (canonical locations)
141151
- `vars/kcli.yml`: Variable override file for persistent configuration
142152
- `roles/kcli/kcli-install/files/pull-secret.json`: OpenShift pull secret
143153
- SSH key automatically read from `~/.ssh/id_ed25519.pub` on ansible controller
144154

145-
#### Assisted Installer Method
146-
- `vars/assisted.yml`: Variable override file (copy from `vars/assisted.yml.template`)
155+
#### Assisted Installer Method (canonical locations)
156+
- `vars/assisted.yml`: Variable override file (create as `config/assisted.yml`)
147157
- Hub cluster must be deployed first via dev-scripts (`make deploy fencing-ipi`)
148158
- Spoke credentials output to `~/<spoke_cluster_name>/auth/` on hypervisor
149159
- Hub proxy preserved as `hub-proxy.env`

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ This repository provides automation for deploying and managing two-node OpenShif
66

77
## Quick Start
88

9+
Configuration files (instance settings, pull secret, topology configs) are created in the central [config/](config/) folder; see [config/README.md](config/README.md) for the full list. Every `make` command syncs them to the locations where the automation reads them. Editing the canonical locations directly still works as before.
10+
911
### Option 1: AWS Hypervisor (Automated)
1012

1113
If you have AWS access, use the automated workflow. Most lifecycle operations can be performed from the [deploy](deploy/) folder using `make`:
@@ -48,6 +50,8 @@ ansible-playbook setup.yml -i inventory.ini # dev-scripts (arbiter or fen
4850
ansible-playbook kcli-install.yml -i inventory.ini # kcli (fencing only)
4951
```
5052

53+
If you created your configuration files in [config/](config/), run `make sync-config` from the [deploy/](deploy/) folder first to distribute them, since the playbooks are invoked directly here.
54+
5155
See [deploy/openshift-clusters/README-external-host.md](deploy/openshift-clusters/README-external-host.md) for detailed instructions.
5256

5357
## Deployment Methods

config/.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Real config files (created by the user, may contain credentials) must never
2+
# be committed. Only templates, examples, the README, and this file are tracked.
3+
*
4+
!.gitignore
5+
!README.md
6+
!*.template
7+
!config_*_example.sh

config/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Central configuration folder
2+
3+
This folder is the single place to create your configuration files for the toolbox.
4+
Every `make` target (and `make sync-config` explicitly) syncs files from here to the
5+
locations where the scripts and playbooks actually read them. A file is only copied
6+
when it is missing at the destination or the `config/` copy is newer, so editing the
7+
canonical locations directly still works as before.
8+
9+
Only templates and examples are tracked in git; the `.gitignore` in this folder
10+
prevents your real config files (including the pull secret) from ever being committed.
11+
12+
## Files
13+
14+
| Create this file | Used by | Synced to | How to create |
15+
|---|---|---|---|
16+
| `instance.env` | AWS hypervisor (all `make` instance targets) | `deploy/aws-hypervisor/instance.env` | `cp config/instance.env.template config/instance.env` |
17+
| `pull-secret.json` | dev-scripts and kcli deployments | `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/pull-secret.json` and `deploy/openshift-clusters/roles/kcli/kcli-install/files/pull-secret.json` | Paste your pull secret from <https://cloud.redhat.com/openshift/install/pull-secret> |
18+
| `config_arbiter.sh` | dev-scripts arbiter topology | `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_arbiter.sh` | `cp config/config_arbiter_example.sh config/config_arbiter.sh` |
19+
| `config_fencing.sh` | dev-scripts fencing topology | `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_fencing.sh` | `cp config/config_fencing_example.sh config/config_fencing.sh` |
20+
| `config_sno.sh` | dev-scripts SNO topology | `deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_sno.sh` | `cp config/config_sno_example.sh config/config_sno.sh` |
21+
| `kcli.yml` | kcli deployment (optional overrides) | `deploy/openshift-clusters/vars/kcli.yml` | `cp config/kcli.yml.template config/kcli.yml` |
22+
| `assisted.yml` | assisted installer spoke deployment | `deploy/openshift-clusters/vars/assisted.yml` | `cp config/assisted.yml.template config/assisted.yml` |
23+
| `init-host.yml.local` | external host initialization (optional RHSM overrides) | `deploy/openshift-clusters/vars/init-host.yml.local` | `cp deploy/openshift-clusters/vars/init-host.yml config/init-host.yml.local` |
24+
25+
## Syncing
26+
27+
The sync runs automatically at the start of every script invoked through the
28+
`deploy/` Makefile. To run it on its own (for example before invoking
29+
`ansible-playbook` directly):
30+
31+
```bash
32+
cd deploy/
33+
make sync-config
34+
```

deploy/openshift-clusters/vars/assisted.yml.template renamed to config/assisted.yml.template

File renamed without changes.

deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_arbiter_example.sh renamed to config/config_arbiter_example.sh

File renamed without changes.

deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_fencing_example.sh renamed to config/config_fencing_example.sh

File renamed without changes.

deploy/openshift-clusters/roles/dev-scripts/install-dev/files/config_sno_example.sh renamed to config/config_sno_example.sh

File renamed without changes.

0 commit comments

Comments
 (0)