Run Ansible from CI with a dedicated ci user - #27
Merged
Conversation
Add a users role that creates the ci automation user (locked password, repo-managed authorized key, NOPASSWD sudo via /etc/sudoers.d/ci) and the letsbuilda service user the minecraft role depends on but nothing created. Deploy via a new ansible-deploy workflow on pushes to main touching ansible/**, gated by the ansible GitHub Environment, connecting as ci with a pinned host key. PRs get an ansible-lint + syntax check job (the existing .ansible-lint config was never actually run in CI). Drop the vault_password_file setting pointing at a nonexistent file and document local runs, CI deploys, and the bootstrap procedure in the README. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0131bYS1tMnLNHUJYQy8HwEW
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0131bYS1tMnLNHUJYQy8HwEW
Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev>
Signed-off-by: Bradley Reynolds <bradley.reynolds@tailstory.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Runs the Ansible playbook from GitHub Actions as a dedicated
ciuser, keeping CI auth and logging separate from human access.Changes
usersrole (first play inplaybook.yaml):ciautomation user: locked password, repo-managed authorized key (files/ci_ed25519.pub,exclusive: true), andNOPASSWD: ALLsudo via a visudo-validated/etc/sudoers.d/ci.letsbuildaservice user (system user,nologin, docker group) — previously consumed by the minecraft role but never created anywhere.ansible-deploy.yamlworkflow: runs the playbook on pushes tomaintouchingansible/**(plusworkflow_dispatch), gated by anansibleGitHub Environment. Connects asci(ANSIBLE_REMOTE_USER), keeps strict host-key checking via the committedansible/known_hosts, and queues (not cancels) overlapping runs via a concurrency group.ansible-lintjob inlint.yaml:ansible-lint+ansible-playbook --syntax-checkon PRs and main — the existingansible/.ansible-lintconfig was never actually installed or run in CI before. No secrets on PR-triggered runs.vault_password_filefromansible.cfg(pointed at a nonexistent file and would abort non-interactive runs; vault is unused), added.gitignorefor it.become_ask_pass = yesstays for humans; CI overrides via env.docs/ansible.md, linked from the README.Remaining setup before the first CI deploy
ansibleGitHub Environment, restrict its deployment branches tomain, and add theSSH_PRIVATE_KEYsecret (the counterpart to the committedci_ed25519.pub).ciuser on microwave (chicken-and-egg — documented indocs/ansible.md).Verification
ansible-lintpasses at the production profile; playbook syntax check passes; all pre-commit hooks pass (zizmor clean in offline mode on both new/modified workflows).🤖 Generated with Claude Code
https://claude.ai/code/session_0131bYS1tMnLNHUJYQy8HwEW
Generated by Claude Code