|
1 | 1 | --- |
2 | | -# Claude Code CLI installation (user-specific via npm) |
| 2 | +# Claude Code CLI installation and managed settings |
| 3 | +# |
| 4 | +# Installs Claude Code CLI and configures system-wide managed settings |
| 5 | +# that apply to all users and cannot be overridden. |
| 6 | +# |
| 7 | +# Settings location: /etc/claude-code/managed-settings.json (Linux) |
| 8 | +# /Library/Application Support/ClaudeCode/managed-settings.json (macOS) |
3 | 9 |
|
4 | 10 | - name: Install Claude Code CLI globally for user (Linux) |
5 | 11 | community.general.npm: |
|
39 | 45 | failed_when: false |
40 | 46 | changed_when: false |
41 | 47 | when: ansible_distribution == 'MacOSX' |
| 48 | + |
| 49 | +# ============================================================================ |
| 50 | +# System-wide Managed Settings |
| 51 | +# ============================================================================ |
| 52 | +# These settings apply to all users and cannot be overridden. |
| 53 | +# - Disables telemetry and error reporting |
| 54 | +# - Disables Co-Authored-By commit attribution |
| 55 | +# - Denies access to sensitive files (.env, secrets, keys, credentials) |
| 56 | + |
| 57 | +- name: Create Claude Code managed settings directory (Linux) |
| 58 | + ansible.builtin.file: |
| 59 | + path: /etc/claude-code |
| 60 | + state: directory |
| 61 | + mode: '0755' |
| 62 | + owner: root |
| 63 | + group: root |
| 64 | + when: ansible_distribution in ['Fedora', 'Ubuntu'] |
| 65 | + |
| 66 | +- name: Create Claude Code managed settings directory (macOS) |
| 67 | + ansible.builtin.file: |
| 68 | + path: /Library/Application Support/ClaudeCode |
| 69 | + state: directory |
| 70 | + mode: '0755' |
| 71 | + owner: root |
| 72 | + group: wheel |
| 73 | + when: ansible_distribution == 'MacOSX' |
| 74 | + |
| 75 | +- name: Install Claude Code managed settings (Linux) |
| 76 | + ansible.builtin.copy: |
| 77 | + dest: /etc/claude-code/managed-settings.json |
| 78 | + mode: '0644' |
| 79 | + owner: root |
| 80 | + group: root |
| 81 | + content: | |
| 82 | + { |
| 83 | + "env": { |
| 84 | + "DISABLE_TELEMETRY": "1", |
| 85 | + "DISABLE_ERROR_REPORTING": "1", |
| 86 | + "DISABLE_BUG_COMMAND": "1", |
| 87 | + "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1" |
| 88 | + }, |
| 89 | + "includeCoAuthoredBy": false, |
| 90 | + "permissions": { |
| 91 | + "deny": [ |
| 92 | + "Read(./.env)", |
| 93 | + "Read(./.env.*)", |
| 94 | + "Read(./secrets/**)", |
| 95 | + "Read(./**/*.pem)", |
| 96 | + "Read(./**/*.key)", |
| 97 | + "Read(./**/credentials*)", |
| 98 | + "Read(./**/*secret*)", |
| 99 | + "Read(~/.ssh/**)", |
| 100 | + "Read(~/.aws/**)", |
| 101 | + "Read(~/.gnupg/**)" |
| 102 | + ] |
| 103 | + } |
| 104 | + } |
| 105 | + when: ansible_distribution in ['Fedora', 'Ubuntu'] |
| 106 | + |
| 107 | +- name: Install Claude Code managed settings (macOS) |
| 108 | + ansible.builtin.copy: |
| 109 | + dest: /Library/Application Support/ClaudeCode/managed-settings.json |
| 110 | + mode: '0644' |
| 111 | + owner: root |
| 112 | + group: wheel |
| 113 | + content: | |
| 114 | + { |
| 115 | + "env": { |
| 116 | + "DISABLE_TELEMETRY": "1", |
| 117 | + "DISABLE_ERROR_REPORTING": "1", |
| 118 | + "DISABLE_BUG_COMMAND": "1", |
| 119 | + "DISABLE_NON_ESSENTIAL_MODEL_CALLS": "1" |
| 120 | + }, |
| 121 | + "includeCoAuthoredBy": false, |
| 122 | + "permissions": { |
| 123 | + "deny": [ |
| 124 | + "Read(./.env)", |
| 125 | + "Read(./.env.*)", |
| 126 | + "Read(./secrets/**)", |
| 127 | + "Read(./**/*.pem)", |
| 128 | + "Read(./**/*.key)", |
| 129 | + "Read(./**/credentials*)", |
| 130 | + "Read(./**/*secret*)", |
| 131 | + "Read(~/.ssh/**)", |
| 132 | + "Read(~/.aws/**)", |
| 133 | + "Read(~/.gnupg/**)" |
| 134 | + ] |
| 135 | + } |
| 136 | + } |
| 137 | + when: ansible_distribution == 'MacOSX' |
0 commit comments