# claude_code role Installs [Claude Code](https://code.claude.com/docs/en/setup) on Ubuntu 20.04+ / Debian 10+ (x64 or ARM64, 4 GB+ RAM). ## Methods | `claude_code_install_method` | What it does | Updates | |---|---|---| | `apt` (default) | Adds Anthropic's signed apt repo (stable or latest channel) and installs the `claude-code` package system-wide. Verifies the signing-key fingerprint before trusting it. | `apt upgrade` / set `claude_code_package_state: latest` | | `native` | Runs Anthropic's installer as `claude_code_user`; binary lands in `~/.local/bin/claude`. | Self-updates in the background | ## Key variables (see `defaults/main.yml`) - `claude_code_apt_channel`: `stable` (about a week behind, skips bad releases) or `latest` - `claude_code_package_state`: `present` or `latest` - `claude_code_native_version`: `latest`, `stable`, or a pinned version like `2.1.89` - `claude_code_settings`: optional dict written to `~/.claude/settings.json` (overwrites the file) ## Use ```bash cp inventory.ini.example inventory.ini # edit hosts ansible-playbook -i inventory.ini install-claude.yml --check # dry run ansible-playbook -i inventory.ini install-claude.yml ``` The remote user needs sudo for the `apt` method. ## After install: authenticate (not automated) Run `claude` once on the server and follow the login prompt, or export `ANTHROPIC_API_KEY` for the user (store it in Ansible Vault, not in the repo). A Pro, Max, Team, Enterprise or Console account is required; the free claude.ai plan does not include Claude Code. Verify with `claude --version` and `claude doctor`.