Make toolkit in agent container customizable #4
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Agents in the containers need applications to work effectively (for example golang tooling to work on golang prjects like gofmt). Make the spawn process of the container accept an ansible script to execute before it drops the root access and the agent user then can use the installed programs and configured environment.
Implemented on
maininb6a789b, released asv0.11.0.harness spawn --setup <playbook.yml>now takes a local Ansible playbook and applies it inside the session container as root before the agent starts, so the agent user can use the installed programs and environment:How it works:
spawnreads/validates the playbook (non-empty, <=256 KiB) and sends it assetupin the create request.kube) backend renders it into aharness-<session>-setupConfigMap, mounts it read-only at/etc/harness-setup/playbook.yml, and setsHARNESS_SETUP.scripts/agent-entrypoint.sh) runsansible-playbook -i localhost, -c localas root, then drops to the unprivileged agent user (uid 10001) viasetprivand execsharness agentd.harness-agentchart gained asetupvalue that renders the same ConfigMap/mount/env.Security: a session with a setup playbook needs to start as root to install packages, so its pod uses a relaxed security context (no
runAsNonRoot, no capability drop) for the setup step; the agent process itself still runs as uid 10001. Sessions without--setupkeep the hardened non-root context. The local process backend has no container and rejects--setuprather than ignoring it. Playbooks are treated as code, not secrets.Tests: kube setup ConfigMap/mount/env/security-context, controller rejection on the process backend, and
--setupfile reading;helm lintand template checks for both values. Docs: README "Custom session tooling", multi-agent, e2e.Note: this changes
Dockerfile.agent(adds ansible + util-linux and the entrypoint), so it needs the agent image rebuilt for the tag. Leaving open for verification.