Repository navigation
github_runner: register through ih-github runner register, over SSM or from the secret (SEC-46 slice 3, PR 3 of 5) - #307
Conversation
…M (SEC-46) SEC-46 slice 3 takes the registration-token secrets away from the runner's instance role, which every job on the runner can use. In the new design the pool's registration Lambda delivers the token over SSM instead: it is encrypted to an RSA key that the instance makes for this delivery, in a ramfs at /run/gha-registration. profile::github_runner::register now has two paths, chosen by the fact registration_token_delivery: - "ssm", set by terraform-aws-actions-runner versions that deliver over SSM: /usr/local/sbin/gha-register-runner (root, 0700) waits for the ciphertext and decrypts it in memory (RSA-OAEP, SHA-256). It runs config.sh as github-runner with the token in ACTIONS_RUNNER_INPUT_TOKEN, not in argv. It deletes the key and the ciphertext on every exit, and on success leaves a marker that makes the Lambda's commands refuse to deliver again. - otherwise: unchanged. ih-github reads the secret <registration_token_secret_prefix>-<instance id>, and Puppet deletes it. This is how module 6.1.0 and older deliver the token. The same change is in the sandbox and development environments' copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GsX4weCxwCX7Lncqv3YhBB
|
Ready for review: 549b618 First round. CI on this commit is green:
Lintian's What to look at:
Generated by Claude Code |
|
Approved 549b618 What I checked:
non-blocking: the Generated by Claude Code |
…hs (SEC-46) SEC-46 slice 3, PR 3 of 5. The instance's half of the SSM delivery now lives in infrahouse-core 1.5.0 and runs through infrahouse-toolkit 2.70.0's `ih-github runner register`, so Puppet is one exec per path: * ssm: as root (only root can read the delivery key), `ih-github runner register --registration-token-delivery ssm --registration-token-wait 300 --runner-user github-runner ...`, timeout 420 s, creates .credentials. * secret (the default, no fact): as github-runner, today's command plus `--registration-token-delivery secret`. The toolkit deletes the secret after a successful registration. Removed: gha-register-runner.sh (all three copies), the file resource that installed it, and the delete_registration_token exec. Both execs call /usr/local/bin/ih-github, where the toolkit's .deb links it, and require Package['infrahouse-toolkit'] (ensure => latest; the register class includes profile::infrahouse_toolkit), so they run only after Puppet brought the toolkit to the repository's latest, 2.70.0 or later. Empty labels are dropped: '' is true in Puppet, so `if $label` kept it and the command got a bare "--label". Same change in modules/ and both environments' copies. debian/changelog moves to 0.1.0-1build338, by hand (no Docker for `make bumpversion`). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GsX4weCxwCX7Lncqv3YhBB
|
Ready for review: 509268d The rework into PR 3 of 5 (SEC-46 slice 3). The approval of What changed since
Your non-blocking point on CI on
What to look at:
https://claude.ai/code/session_01GsX4weCxwCX7Lncqv3YhBB Generated by Claude Code |
|
Approved 509268d What I checked. I read the full diff against The fact still defaults to non-blocking: Generated by Claude Code |
SEC-46, slice 3, PR 3 of 5 (puppet-code). Design: the note, the answers and the approval, unchanged.
ih-github runner register --registration-token-delivery ssm|secret|githubexecper path that calls the toolkitWhy
Today any job on a runner can read the pool's pending registration tokens, because the instance role reads
<registration_token_secret_prefix>-<instance id>from Secrets Manager. In slice 3 the registration Lambda delivers the token over SSM instead, and the role loses both Secrets Manager grants (PR 4).This PR first added the instance's side as a bash script,
gha-register-runner.sh, copied into the three trees and not unit-tested (approved at549b618). Aleks then decided that the protocol lives in infrahouse-core and that the instance's half runs through the toolkit (SEC-46, "Where the code lives", step 3). Both are released: infrahouse-core 1.5.0 and infrahouse-toolkit 2.70.0, which is inrelease-noble.infrahouse.comfor amd64 and arm64. So Puppet now only calls the toolkit.What changes
profile::github_runner::registerhas oneexec { 'register_runner': }per path. The factregistration_token_deliverychooses the path:profile::github_runnerreads it withpick_default(…, 'secret'), and the class takesEnum['ssm', 'secret'] $token_delivery. Both are unchanged from the first round, so a pool on terraform-aws-actions-runner 6.1.0 or older, which doesn't set the fact, keeps the secret path.ssm. The exec runs as root, because only root can read the delivery key:The toolkit waits for the ciphertext, decrypts it in memory, runs
config.shasgithub-runnerwith the token only inACTIONS_RUNNER_INPUT_TOKEN, and deletes the key and the ciphertext whatever happens. A runner that already registered with a delivered token (the marker) exits 0. Any failure exits non-zero: Puppet fails, and the bootstrap lifecycle hook abandons the instance.creates => <dir>/.credentials, as in the first round.timeout => 420: the 300 s wait plusconfig.sh, inside the hook's 1200 s.secret. The exec runs asgithub-runner, as today:The toolkit reads the secret, runs
config.shwith the token inACTIONS_RUNNER_INPUT_TOKEN(before 2.70.0 it was in argv), and deletes the secret after a successful registration. A failed delete only warns. A failed registration leaves the secret for the next run.On both paths no token is on the exec's command line.
Removed:
gha-register-runner.sh(all three copies), thefileresource that installed it as/usr/local/sbin/gha-register-runner, and thedelete_registration_tokenexec. The toolkit deletes the secret itself. No Puppet run ever installed the script, because no module version sets the fact yet. So no host has a copy to remove.The toolkit version. Both execs
require => Package['infrahouse-toolkit'].profile::infrahouse_toolkitdeclares that package withensure => latest.profile::reposrunsapt-get updatein stageiniton every run. The release repository keeps every version, and Puppet never downgrades. So once the package resource is in sync, the toolkit is the repository's latest, 2.70.0 or later. If the package resource fails, Puppet skips the exec. The register class includesprofile::infrahouse_toolkititself, so the reference resolves even where a role doesn't includeprofile::base.role::github_runnerincludes both today. Without therequire, only Puppet's default manifest ordering put the package first:profile::basecomes beforeprofile::github_runnerin the role.path. The command is/usr/local/bin/ih-github, where the toolkit's.deblinks it (packaging/nfpm.yamlat v2.70.0:/opt/infrahouse-toolkit/embedded/bin/ih-github→/usr/local/bin/ih-github).path => '/usr/local/bin:/usr/bin:/bin'.config.shgets its ownPATHfrom the toolkit (CONFIG_PATH). The runner directory is no longer on the secret exec'spath: nothing runs from there by its bare name.Labels. One
--labelper label, the form the toolkit's--labeltakes (multiple=True): the Hiera labels,instance_id:<id>and the factlabels. Empty labels are dropped. This fixes a bug in today's code:''is true in Puppet, soif $labelkept it, and the command got a bare--label, which takes the next word as its value.undefwas already dropped, and still is.Docs. The class's header and
@params describe the two paths as above. The script isn't mentioned.The trees.
modules/profileand both environments' copies differ only where they differed onmainbefore this PR:apt_lock_timeout.ppexists only in the environments, andrepos.ppdiffers (diff -rq).debian/changelog: one new entry,0.1.0-1build338, after the first round'sbuild337. I wrote it by hand indch -R's format, becausehooks/pre-commitrunsmake bumpversionin Docker, which isn't available where this was written.Checks
--fail-on-warningson the four paths inhooks/pre-commit(modules/profile,modules/role,environments/development/modules/profile,environments/sandbox/modules/profile):space_before_arrowonly inbase.pp,elastic/prometheus.ppandteleport/packages.ppand their copies. This PR doesn't touch those files, and the reports are the same onmain.register.pp: clean.puppet parser validate(Puppet 8.10.0) on the three changed manifests: clean.profile::github_runner::register, with the realprofile::infrahouse_toolkit, a stubExec[extract_runner_package]and stub facts (instancei-0123456789abcdef0, fact labels[noble, "", awesome]):registration_token_delivery: ssm:secret):Exec[delete_registration_token]and noFile[/usr/local/sbin/gha-register-runner].puppet apply --noopof the same code appliesExec[extract_runner_package], thenPackage[infrahouse-toolkit], thenExec[register_runner], with either fact.--registration-token-wait 0instead of 300. Both parse and reach the registration, which fails as it should there, with exit 1: "There is no user github-runner to run config.sh as." and an invalid-credentialsGetSecretValueerror. Neither got exit 2, the usage error. With 2.69.0 both exit 2,No such option '--registration-token-delivery', before any secret or delivery is read. So a host with an old toolkit fails closed and the instance is abandoned. No token is exposed.CI.yml) builds the.debfor noble. Its result on the head commit is in theReady for reviewcomment.After merge
CD (
CD.yml, on push tomain) builds the package and publishes it toinfrahouse-release-noble. To check that the published package has the change:Nothing changes on the running pools. No module version sets the fact yet, so new runners take the secret path through the toolkit until PR 4 ships. Runners that are already registered have
.credentials, so the exec doesn't run on them.Next step
Aleks: merge, and check that CD published
0.1.0-1build338. Then PR 4 (terraform-aws-actions-runner) sets the factregistration_token_deliverytossmand takes the secret grants off the instance role. Its CI must run after this package is published.decided
--registration-token-wait 300is passed explicitly. It's the toolkit's default too. Passing it puts the number next to thetimeout => 420that must cover it, and a later change of the toolkit's default can't push the wait past the timeout.require => Package['infrahouse-toolkit'], and the register class includesprofile::infrahouse_toolkit. There's noDepends: infrahouse-toolkit (>= 2.70.0)indebian/controland no separate version-check exec. Withensure => latest, therequirealready means "the repository's latest", and 2.70.0 is in the repository. An older toolkit fails the exec with a usage error (exit 2) before it reads a token, so it fails closed. A package dependency would change every host's packaging for one role./usr/local/bin/ih-github, andpathis set too, with/usr/local/binfirst. Anih-githubfrom an older pip install elsewhere onPATHcan't be the one that runs.--org <org>, which the toolkit ignores on that path. The command stays today's plus--registration-token-delivery secret. The ssm exec doesn't pass--org.--labelper label, as the toolkit takes them.$label =~ NotUndef and $label != ''). Today'sif $labeldidn't drop it.secret. Aleks owns removing the secret path, with the module's 7.0.0. (design)https://claude.ai/code/session_01GsX4weCxwCX7Lncqv3YhBB
Generated by Claude Code