| e3fd8257 Andy McCall ↶ |
1 |
# The OxygenFlow OpenTofu image |
| 2 |
|
| 3 |
A root file system for deploy jobs (oxygenflow#56): |
| 4 |
|
| 5 |
- Debian bookworm, slim, with CA certificates. |
| 6 |
- OpenTofu 1.13.1, checked against its published SHA-256. |
| e0053e04 Andy McCall ↶ |
7 |
- A provider mirror in `/opt/tofu/mirror`: `hashicorp/google` 8.7.0, |
| 8 |
`hashicorp/google-beta` 8.7.0 (Firebase) and `cloudflare/cloudflare` |
| 9 |
5.28.0, checked by `tofu providers mirror` against the registry's signed |
| 10 |
checksums when the image is built. |
| e3fd8257 Andy McCall ↶ |
11 |
- `/etc/tofu/cli.tfrc` (set by `TF_CLI_CONFIG_FILE`) installs providers |
| 12 |
from the mirror only. |
| 1c9afa92 Andy McCall ↶ |
13 |
- TFLint 0.64.0 and its Google ruleset 0.40.0, each checked against its |
| 14 |
release's SHA-256, the ruleset in `/opt/tflint/plugins` |
| 15 |
(`TFLINT_PLUGIN_DIR`): a repository's `.tflint.hcl` enables it with |
| 16 |
`plugin "google" { enabled = true version = "0.40.0" source = |
| 17 |
"github.com/terraform-linters/tflint-ruleset-google" }`, and linting |
| 18 |
needs no `tflint --init`. |
| e3fd8257 Andy McCall ↶ |
19 |
|
| 20 |
So `tofu init`, `fmt` and `validate` need no network; `plan` and `apply` |
| 21 |
reach the cloud's APIs through allow-listed egress (#55). The guest's |
| 22 |
environment is the pipeline's, so a job sets `TF_CLI_CONFIG_FILE` itself |
| 23 |
(below). |
| 24 |
|
| 25 |
## Building and importing |
| 26 |
|
| 27 |
``` |
| 28 |
images/tofu/build.sh /path/to/oxygenflow-tofu.tar |
| 29 |
scp /path/to/oxygenflow-tofu.tar claude@earth:/home/claude/flow/dl/ |
| 30 |
ssh claude@earth 'cd ~/flow && FLOW_HOME=~/flow bin/flow rootfs import dl/oxygenflow-tofu.tar' |
| 31 |
``` |
| 32 |
|
| 33 |
Pin the printed hash in the pipelines that use it, and push it to the hub |
| 34 |
(`flow rootfs push HASH`) so every runner can fetch it. |
| 35 |
|
| 36 |
A provider version in a pipeline's lock file must be in the mirror: bump |
| 37 |
`mirror.tf`, rebuild and re-pin when a lock file changes. |
| 38 |
|
| 39 |
## Using it |
| 40 |
|
| 41 |
```kdl |
| 42 |
sandbox "tofu" { |
| 43 |
runtime "microvm" |
| 44 |
rootfs "cas://blob/<hash printed by flow rootfs import>" |
| 45 |
memory-limit "2GiB" |
| 46 |
cpu-limit 2 |
| 47 |
network "isolated" |
| 48 |
env { |
| 49 |
TF_CLI_CONFIG_FILE "/etc/tofu/cli.tfrc" |
| 50 |
TF_IN_AUTOMATION "1" |
| 1c9afa92 Andy McCall ↶ |
51 |
TFLINT_PLUGIN_DIR "/opt/tflint/plugins" |
| e3fd8257 Andy McCall ↶ |
52 |
} |
| 53 |
} |
| 54 |
``` |