Skip to content

Commit 8c02cd3

Browse files
committed
feat(setup/runner): add bootstrap-linux-runner, bootstrap-macos-runner, install-docker, install-k8s-tools, install-cloud-clis, and runner-healthcheck with docs
1 parent e51408e commit 8c02cd3

13 files changed

Lines changed: 1654 additions & 1 deletion
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# bootstrap-linux-runner.sh
2+
3+
## Purpose
4+
Bootstrap a Linux runner with required tooling and baseline configuration for devops.scripts automation.
5+
6+
## Location
7+
`setup/runner/bootstrap-linux-runner.sh`
8+
9+
## Preconditions
10+
- Required tools: `bash`, package manager (`apt`/`dnf`/`yum`/`brew`), optional `sudo`
11+
- Required permissions: package install and system service privileges for full setup
12+
- Required environment variables: none
13+
14+
## Arguments
15+
| Flag | Required | Default | Description |
16+
|------|----------|---------|-------------|
17+
| `--manager NAME` | No | `auto` | Package manager selector |
18+
| `--yes` | No | `false` | Non-interactive install mode |
19+
| `--dry-run` | No | `false` | Print actions without execution |
20+
| `--update-cache` | No | `false` | Refresh package metadata |
21+
| `--skip-docker` | No | `false` | Skip Docker setup |
22+
| `--skip-k8s` | No | `false` | Skip Kubernetes tool setup |
23+
| `--skip-cloud` | No | `false` | Skip cloud CLI setup |
24+
| `--skip-healthcheck` | No | `false` | Skip final runner healthcheck |
25+
26+
## Scenarios
27+
- Happy path: full bootstrap succeeds and runner healthcheck passes.
28+
- Common operational path: run with selective `--skip-*` flags for targeted provisioning.
29+
- Failure path: missing package manager/sudo or downstream installer failure.
30+
- Recovery/rollback path: fix failing step and rerun bootstrap idempotently.
31+
32+
## Usage
33+
```bash
34+
setup/runner/bootstrap-linux-runner.sh --yes --update-cache
35+
setup/runner/bootstrap-linux-runner.sh --manager apt --skip-cloud
36+
setup/runner/bootstrap-linux-runner.sh --dry-run
37+
```
38+
39+
## Behavior
40+
- Main execution flow: calls setup/local and setup/runner installers + baseline configs + healthcheck.
41+
- Idempotency notes: orchestrator is rerunnable; underlying installers skip existing tools when possible.
42+
- Side effects: package installs, config updates, optional docker service enable/start.
43+
44+
## Output
45+
- Standard output format: timestamped step logs.
46+
- Exit codes:
47+
- `0` successful bootstrap
48+
- non-zero from failing step
49+
- `2` invalid arguments or unsupported OS
50+
51+
## Failure Modes
52+
- Common errors and likely causes:
53+
- not running on Linux
54+
- package install failures/repository issues
55+
- missing privileges for service or package operations
56+
- Recovery and rollback steps:
57+
- rerun failed sub-script directly for diagnosis
58+
- fix package repos/permissions
59+
- rerun bootstrap with required flags
60+
61+
## Security Notes
62+
- Secret handling: no secrets required by default.
63+
- Least-privilege requirements: use least privilege; elevate only for install/service actions.
64+
- Audit/logging expectations: preserve bootstrap logs in runner build artifacts.
65+
66+
## Testing
67+
- Unit tests:
68+
- flag parsing and skip logic
69+
- Integration tests:
70+
- container/VM bootstrap validation on Linux distributions
71+
- Manual verification:
72+
- run `setup/runner/runner-healthcheck.sh` after bootstrap
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# bootstrap-macos-runner.sh
2+
3+
## Purpose
4+
Bootstrap a macOS runner with required tooling and baseline configuration for devops.scripts automation.
5+
6+
## Location
7+
`setup/runner/bootstrap-macos-runner.sh`
8+
9+
## Preconditions
10+
- Required tools: `bash`, Homebrew (`brew`) or `--install-brew` path
11+
- Required permissions: package install permissions
12+
- Required environment variables: none
13+
14+
## Arguments
15+
| Flag | Required | Default | Description |
16+
|------|----------|---------|-------------|
17+
| `--yes` | No | `false` | Non-interactive install mode |
18+
| `--dry-run` | No | `false` | Print actions without execution |
19+
| `--update-cache` | No | `false` | Refresh package metadata |
20+
| `--skip-docker` | No | `false` | Skip Docker installation |
21+
| `--skip-k8s` | No | `false` | Skip Kubernetes tool setup |
22+
| `--skip-cloud` | No | `false` | Skip cloud CLI setup |
23+
| `--skip-healthcheck` | No | `false` | Skip final runner healthcheck |
24+
| `--install-brew` | No | `false` | Install Homebrew if missing |
25+
26+
## Scenarios
27+
- Happy path: Homebrew present, tools configured, healthcheck passes.
28+
- Common operational path: bootstrap managed macOS runners for CI jobs.
29+
- Failure path: Homebrew missing and `--install-brew` not provided, or install failures.
30+
- Recovery/rollback path: install Homebrew/dependencies and rerun.
31+
32+
## Usage
33+
```bash
34+
setup/runner/bootstrap-macos-runner.sh --yes --update-cache
35+
setup/runner/bootstrap-macos-runner.sh --skip-cloud
36+
setup/runner/bootstrap-macos-runner.sh --dry-run --install-brew
37+
```
38+
39+
## Behavior
40+
- Main execution flow: install base/local/runner tools and apply local configurations.
41+
- Idempotency notes: rerunnable orchestration with skip/installed checks.
42+
- Side effects: package installs, configuration file updates.
43+
44+
## Output
45+
- Standard output format: timestamped step logs.
46+
- Exit codes:
47+
- `0` successful bootstrap
48+
- non-zero from failing step
49+
- `2` invalid arguments or unsupported OS
50+
51+
## Failure Modes
52+
- Common errors and likely causes:
53+
- script run on non-macOS host
54+
- Homebrew install/access issues
55+
- sub-installer failure
56+
- Recovery and rollback steps:
57+
- validate brew setup and network access
58+
- rerun failing sub-script directly
59+
- rerun bootstrap with corrected flags
60+
61+
## Security Notes
62+
- Secret handling: no default secret requirements.
63+
- Least-privilege requirements: local user-level operations preferred.
64+
- Audit/logging expectations: retain bootstrap logs for runner provenance.
65+
66+
## Testing
67+
- Unit tests:
68+
- flag and step selection behavior
69+
- Integration tests:
70+
- macOS CI runner bootstrap smoke test
71+
- Manual verification:
72+
- run `setup/runner/runner-healthcheck.sh` post-bootstrap
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# install-cloud-clis.sh
2+
3+
## Purpose
4+
Install cloud provider CLIs for AWS, GCP, and Azure operations on runners.
5+
6+
## Location
7+
`setup/runner/install-cloud-clis.sh`
8+
9+
## Preconditions
10+
- Required tools: `bash`, package manager, optional `sudo`
11+
- Required permissions: package installation privileges
12+
- Required environment variables: none
13+
14+
## Arguments
15+
| Flag | Required | Default | Description |
16+
|------|----------|---------|-------------|
17+
| `--tools CSV` | No | `aws,gcloud,az` | Tool set to install |
18+
| `--tool NAME` | No | none | Add one tool (repeatable) |
19+
| `--manager NAME` | No | `auto` | `auto\|brew\|apt\|dnf\|yum` |
20+
| `--yes` | No | `false` | Non-interactive mode |
21+
| `--update-cache` | No | `false` | Refresh package metadata |
22+
| `--dry-run` | No | `false` | Print commands only |
23+
24+
## Scenarios
25+
- Happy path: cloud CLIs installed and ready for auth/bootstrap.
26+
- Common operational path: install subset of provider CLIs for environment-specific runners.
27+
- Failure path: package repo lacks provider package or permissions are insufficient.
28+
- Recovery/rollback path: adjust manager/repository or install subset and rerun.
29+
30+
## Usage
31+
```bash
32+
setup/runner/install-cloud-clis.sh --yes
33+
setup/runner/install-cloud-clis.sh --tools aws,gcloud
34+
setup/runner/install-cloud-clis.sh --tool az --dry-run
35+
```
36+
37+
## Behavior
38+
- Main execution flow: parse tool list, map package names, install missing commands.
39+
- Idempotency notes: existing CLIs are skipped.
40+
- Side effects: package installation.
41+
42+
## Output
43+
- Standard output format: timestamped install logs.
44+
- Exit codes:
45+
- `0` all requested tools installed/present
46+
- `1` one or more tools failed/unsupported
47+
- `2` invalid arguments
48+
49+
## Failure Modes
50+
- Common errors and likely causes:
51+
- unsupported tool name
52+
- package unavailable in configured repositories
53+
- permission failures on install
54+
- Recovery and rollback steps:
55+
- verify repositories and manager selection
56+
- rerun with corrected tool list or permissions
57+
58+
## Security Notes
59+
- Secret handling: no credentials handled during install.
60+
- Least-privilege requirements: elevate only during package operations.
61+
- Audit/logging expectations: installation actions should be logged in runner provisioning.
62+
63+
## Testing
64+
- Unit tests:
65+
- tool parsing/mapping validation
66+
- Integration tests:
67+
- install flow on each supported package manager
68+
- Manual verification:
69+
- `aws --version`, `gcloud --version`, `az version`
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# install-docker.sh
2+
3+
## Purpose
4+
Install Docker and optionally start/enable the daemon on Linux runners.
5+
6+
## Location
7+
`setup/runner/install-docker.sh`
8+
9+
## Preconditions
10+
- Required tools: `bash`, package manager, optional `sudo`, optional `systemctl`
11+
- Required permissions: package install privileges; service management for daemon actions
12+
- Required environment variables: none
13+
14+
## Arguments
15+
| Flag | Required | Default | Description |
16+
|------|----------|---------|-------------|
17+
| `--manager NAME` | No | `auto` | `auto\|brew\|apt\|dnf\|yum` |
18+
| `--yes` | No | `false` | Non-interactive install mode |
19+
| `--update-cache` | No | `false` | Refresh package metadata |
20+
| `--start-service` | No | `true` | Start/enable daemon on Linux |
21+
| `--no-start-service` | No | `false` | Skip daemon startup |
22+
| `--add-user-to-docker-group` | No | `false` | Add user to docker group (Linux) |
23+
| `--dry-run` | No | `false` | Print commands only |
24+
25+
## Scenarios
26+
- Happy path: Docker installed and daemon started (Linux).
27+
- Common operational path: install binary only in immutable environments.
28+
- Failure path: missing package manager or insufficient privileges.
29+
- Recovery/rollback path: fix package/service permissions and rerun.
30+
31+
## Usage
32+
```bash
33+
setup/runner/install-docker.sh --yes --update-cache
34+
setup/runner/install-docker.sh --manager apt --no-start-service
35+
setup/runner/install-docker.sh --add-user-to-docker-group
36+
```
37+
38+
## Behavior
39+
- Main execution flow: detect manager, install package if needed, manage service/group options.
40+
- Idempotency notes: skip install when docker already exists.
41+
- Side effects: package install, daemon state changes, optional group membership changes.
42+
43+
## Output
44+
- Standard output format: timestamped progress logs.
45+
- Exit codes:
46+
- `0` success
47+
- `1` install/runtime failure
48+
- `2` invalid arguments
49+
50+
## Failure Modes
51+
- Common errors and likely causes:
52+
- unsupported manager selection
53+
- package not found in repositories
54+
- no permission for service/group updates
55+
- Recovery and rollback steps:
56+
- verify repositories and package availability
57+
- rerun with elevated privileges where required
58+
59+
## Security Notes
60+
- Secret handling: none.
61+
- Least-privilege requirements: avoid unnecessary root usage outside install/service steps.
62+
- Audit/logging expectations: record daemon/group changes for compliance.
63+
64+
## Testing
65+
- Unit tests:
66+
- manager detection and option validation
67+
- Integration tests:
68+
- install/start behavior on Linux/macOS test images
69+
- Manual verification:
70+
- `docker --version` and `docker info`
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# install-k8s-tools.sh
2+
3+
## Purpose
4+
Install core Kubernetes ecosystem CLIs required for cluster operations and CI automation.
5+
6+
## Location
7+
`setup/runner/install-k8s-tools.sh`
8+
9+
## Preconditions
10+
- Required tools: `bash`, package manager, optional `sudo`
11+
- Required permissions: package installation privileges
12+
- Required environment variables: none
13+
14+
## Arguments
15+
| Flag | Required | Default | Description |
16+
|------|----------|---------|-------------|
17+
| `--tools CSV` | No | `kubectl,helm,kustomize,kind` | Tool set to install |
18+
| `--tool NAME` | No | none | Add one tool (repeatable) |
19+
| `--manager NAME` | No | `auto` | `auto\|brew\|apt\|dnf\|yum` |
20+
| `--yes` | No | `false` | Non-interactive mode |
21+
| `--update-cache` | No | `false` | Refresh package metadata |
22+
| `--dry-run` | No | `false` | Print commands only |
23+
24+
## Scenarios
25+
- Happy path: requested Kubernetes tools installed successfully.
26+
- Common operational path: install only subset needed by specific runner pools.
27+
- Failure path: unsupported tool/manager mapping or install failure.
28+
- Recovery/rollback path: adjust tool list/manager and rerun.
29+
30+
## Usage
31+
```bash
32+
setup/runner/install-k8s-tools.sh --yes
33+
setup/runner/install-k8s-tools.sh --tools kubectl,helm
34+
setup/runner/install-k8s-tools.sh --tool kind --tool kustomize --dry-run
35+
```
36+
37+
## Behavior
38+
- Main execution flow: normalize tool list, map package names per manager, install missing tools.
39+
- Idempotency notes: skips tools already present.
40+
- Side effects: package installation.
41+
42+
## Output
43+
- Standard output format: timestamped install logs.
44+
- Exit codes:
45+
- `0` all requested tools installed/present
46+
- `1` one or more tools failed/unsupported
47+
- `2` invalid arguments
48+
49+
## Failure Modes
50+
- Common errors and likely causes:
51+
- unsupported tool name
52+
- package unavailable in repo
53+
- missing privileges for install
54+
- Recovery and rollback steps:
55+
- fix tool names and manager mapping
56+
- ensure repository availability
57+
58+
## Security Notes
59+
- Secret handling: none.
60+
- Least-privilege requirements: elevate only for package operations.
61+
- Audit/logging expectations: capture install outcomes in bootstrap logs.
62+
63+
## Testing
64+
- Unit tests:
65+
- tool parsing and manager mapping
66+
- Integration tests:
67+
- installation on supported package managers
68+
- Manual verification:
69+
- `kubectl version --client`, `helm version`, `kind version`

0 commit comments

Comments
 (0)