auberge 0.9.2

CLI tool for managing self-hosted infrastructure with Ansible
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
# Check Mode (Dry Run)

Check mode allows you to preview changes before applying them, similar to a dry run.

## Overview

**Purpose:** See what Ansible would change without actually changing anything

**Command:**

```bash
auberge deploy --check
```

**Output:** Shows tasks that would execute and whether they would make changes

## Usage

### Deploy Check Mode (Primary)

```bash
# Interactive: select app(s) and host, then dry-run
auberge deploy --check

# Check a specific app
auberge deploy paperless --check

# Check all apps on a specific host
auberge deploy --all --host auberge --check
```

### Power-User: ansible run --check

For lower-level control (specific playbooks, skip-tags, etc.):

```bash
auberge ansible run --host auberge --playbook playbooks/apps.yml --check

# With skip-tags
auberge ansible run --host auberge --playbook playbooks/apps.yml --check --skip-tags navidrome

# With explicit tags
auberge ansible run --host auberge --check --tags baikal
```

## Understanding Output

### Status Indicators

Check mode uses the same status indicators as normal mode:

**ok (green):**

```
TASK [caddy : Check Caddy binary exists] ****
ok: [auberge]
```

- Task would run
- No changes would be made
- System already in desired state

**changed (yellow):**

```
TASK [baikal : Deploy Baikal config] ****
changed: [auberge]
```

- Task would make changes
- File/service/package would be modified
- **This is what you're looking for** in check mode

**skipped (cyan):**

```
TASK [bootstrap : Create ansible user] ****
skipping: [auberge]
```

- Task would be skipped
- Conditional not met (e.g., user already exists)

**failed (red):**

```
TASK [fail2ban : Start fail2ban service] ****
failed: [auberge]
```

- Task would fail
- Usually due to missing dependencies
- May be false positive in check mode (see limitations)

### Example Output

```
TASK [baikal : Install Baikal] ****
ok: [auberge]

TASK [baikal : Deploy configuration] ****
changed: [auberge]

TASK [baikal : Create data directory] ****
ok: [auberge]

TASK [baikal : Deploy systemd service] ****
changed: [auberge]

TASK [baikal : Start Baikal service] ****
changed: [auberge]

PLAY RECAP ****
auberge  : ok=15  changed=3  unreachable=0  failed=0  skipped=2
```

**Interpretation:**

- 3 tasks would make changes
- 15 tasks would run without changes
- 2 tasks would be skipped
- 0 failures

## What Check Mode Shows

### Files Changes

Shows whether files would be:

- Created
- Modified
- Deleted

**Example:**

```
TASK [caddy : Deploy Caddyfile] ****
changed: [auberge]
```

**Meaning:** Caddyfile content differs from template → would be updated

### Package Changes

Shows whether packages would be:

- Installed
- Updated
- Removed

**Example:**

```
TASK [apt : Install essential packages] ****
ok: [auberge]
```

**Meaning:** All packages already installed at correct version

### Service Changes

Shows whether services would be:

- Started
- Stopped
- Restarted
- Enabled/disabled

**Example:**

```
TASK [baikal : Restart Baikal] ****
changed: [auberge]
```

**Meaning:** Service would be restarted (likely due to config change)

### User/Group Changes

Shows whether users/groups would be:

- Created
- Modified
- Removed

**Example:**

```
TASK [ansible_user : Create ansible user] ****
ok: [auberge]
```

**Meaning:** User already exists with correct settings

## Limitations

Check mode has some limitations due to its non-destructive nature:

### 1. Dependency Failures

Tasks that depend on previous tasks may fail:

**Scenario:**

```yaml
- name: Create directory
  ansible.builtin.file:
    path: /app/data
    state: directory

- name: Copy file to directory
  ansible.builtin.copy:
    src: config.yml
    dest: /app/data/config.yml
```

**Check mode:** First task shows "changed", but directory isn't actually created. Second task may fail because directory doesn't exist.

**Workaround:** Ignore these failures - they wouldn't occur in real execution.

### 2. Conditional Logic

Some tasks check system state and conditionally execute:

```yaml
- name: Reload service
  ansible.builtin.systemd:
    name: baikal
    state: reloaded
  when: config_changed
```

**Check mode:** Condition might evaluate incorrectly if dependent task didn't actually run.

### 3. Command Modules

`ansible.builtin.command` and `ansible.builtin.shell` show "changed" even if they wouldn't change anything:

```yaml
- name: Get system info
  ansible.builtin.command: uname -a
  register: uname_output
```

**Check mode:** Always shows "changed" (because it doesn't actually run the command to check).

**Workaround:** Use `check_mode: no` for read-only commands:

```yaml
- name: Get system info
  ansible.builtin.command: uname -a
  register: uname_output
  check_mode: no # Always run, even in check mode
```

### 4. Handlers

Handlers are triggered but not executed:

```yaml
tasks:
  - name: Deploy config
    ansible.builtin.template:
      src: config.j2
      dest: /etc/app/config.yml
    notify: Restart app

handlers:
  - name: Restart app
    ansible.builtin.systemd:
      name: app
      state: restarted
```

**Check mode:**

- Task shows "changed"
- Handler is notified
- Handler doesn't actually restart service

**Output:**

```
RUNNING HANDLER [Restart app] ****
changed: [auberge]
```

**Meaning:** Handler would run, but service isn't actually restarted in check mode.

## Use Cases

### Before Deployment

Preview changes before deploying:

```bash
# Check what would change
auberge deploy paperless --check --host auberge

# If output looks good, deploy
auberge deploy paperless --host auberge
```

### After Config Changes

Verify your changes would apply correctly:

```bash
# Edit configuration
vim ansible/roles/baikal/templates/config.j2

# Check what would change
auberge deploy baikal --check --host auberge

# Review output, then apply
auberge deploy baikal --host auberge
```

### Testing New Playbooks

Test playbooks before first execution:

```bash
# Check new playbook (power-user)
auberge ansible run --host staging --playbook playbooks/new-feature.yml --check

# Review output for errors or unexpected changes
# Fix issues, re-check
# Deploy when ready
```

### Auditing Infrastructure

See what's out of sync with desired state:

```bash
auberge deploy --all --check --host auberge
```

**If many "changed" tasks:** System has drifted from configuration

**If few "changed" tasks:** System is consistent with playbooks

## Combining with Verbosity

For verbose output, use `ansible run` directly:

```bash
auberge ansible run --host auberge --check --tags baikal -vv
```

**Example output with `-v`:**

```
TASK [baikal : Deploy config] ****
changed: [auberge]
--- before: /etc/baikal/config
+++ after: /tmp/ansible-tmp-*/config.j2
@@ -1,3 +1,3 @@
 [server]
-hosts = 127.0.0.1:5232
+hosts = 0.0.0.0:5232
```

Shows **diff** of what would change.

## Diff Mode

Show file differences for all tasks (power-user):

```bash
auberge ansible run --host auberge --playbook playbooks/apps.yml --check --diff
```

**Output:**

```
TASK [caddy : Deploy Caddyfile] ****
--- before: /etc/caddy/Caddyfile
+++ after: /tmp/ansible-tmp-1234/Caddyfile.j2
@@ -10,6 +10,10 @@
 rss.example.com {
     reverse_proxy localhost:8000
 }
+
+music.example.com {
+    reverse_proxy localhost:4533
+}
```

**Benefit:** See exact changes before applying.

## Real Execution After Check

Check mode and normal mode are independent:

```bash
# Check mode does NOT affect system
auberge deploy paperless --check --host auberge

# Normal mode still needed to apply changes
auberge deploy paperless --host auberge
```

Check mode is **read-only** - it never modifies the system.

## Best Practices

### Always Check Before Major Changes

```bash
# Before full stack deployment
auberge deploy --all --check --host auberge

# Review output carefully
# Then deploy
auberge deploy --all --host auberge
```

### Combine with Backup

For production systems:

```bash
# 1. Create backup
auberge backup create --host production

# 2. Check what would change
auberge deploy --all --check --host production

# 3. If safe, apply
auberge deploy --all --host production

# 4. Verify, or restore if needed
```

### Use App Targeting for Focused Checks

```bash
# Check only what you're changing
auberge deploy baikal --check --host auberge
```

### Ignore Expected Failures

Some failures in check mode are normal:

- Missing directories that would be created
- Services that would be installed
- Dependencies not yet deployed

**Focus on:** Tasks that should already exist but show "changed" or "failed" unexpectedly.

## Related Pages

- [Running Playbooks]deployment/running-playbooks.md - Actual execution
- [Tags]deployment/tags.md - Selective execution
- [Playbooks]core-concepts/playbooks.md - Playbook structure