container-superposition 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/scripts/generate-schema.d.ts +14 -0
- package/dist/scripts/generate-schema.d.ts.map +1 -0
- package/dist/scripts/generate-schema.js +406 -0
- package/dist/scripts/generate-schema.js.map +1 -0
- package/dist/tool/cli/args.d.ts.map +1 -1
- package/dist/tool/cli/args.js +1 -1
- package/dist/tool/cli/args.js.map +1 -1
- package/dist/tool/commands/adopt.d.ts.map +1 -1
- package/dist/tool/commands/adopt.js +14 -20
- package/dist/tool/commands/adopt.js.map +1 -1
- package/dist/tool/questionnaire/composer.d.ts.map +1 -1
- package/dist/tool/questionnaire/composer.js +186 -2
- package/dist/tool/questionnaire/composer.js.map +1 -1
- package/dist/tool/readme/readme-generator.d.ts.map +1 -1
- package/dist/tool/readme/readme-generator.js +1 -1
- package/dist/tool/readme/readme-generator.js.map +1 -1
- package/dist/tool/schema/project-config.d.ts +8 -1
- package/dist/tool/schema/project-config.d.ts.map +1 -1
- package/dist/tool/schema/project-config.js +180 -6
- package/dist/tool/schema/project-config.js.map +1 -1
- package/dist/tool/schema/types.d.ts +51 -1
- package/dist/tool/schema/types.d.ts.map +1 -1
- package/docs/README.md +1 -0
- package/docs/overlays.md +40 -0
- package/docs/specs/019-project-mounts/spec.md +176 -0
- package/docs/specs/020-superposition-yml-schema.md +83 -0
- package/docs/specs/021-deterministic-generated-readme/spec.md +70 -0
- package/docs/superposition-yml.md +481 -0
- package/overlays/ansible/README.md +163 -0
- package/overlays/ansible/devcontainer.patch.json +14 -0
- package/overlays/ansible/overlay.yml +18 -0
- package/overlays/argocd/README.md +158 -0
- package/overlays/argocd/devcontainer.patch.json +9 -0
- package/overlays/argocd/overlay.yml +17 -0
- package/overlays/argocd/setup.sh +29 -0
- package/overlays/argocd/verify.sh +14 -0
- package/overlays/pi/README.md +141 -0
- package/overlays/pi/devcontainer.patch.json +6 -0
- package/overlays/pi/overlay.yml +15 -0
- package/overlays/pi/setup.sh +28 -0
- package/overlays/pi/verify.sh +23 -0
- package/overlays/task/README.md +47 -0
- package/overlays/task/devcontainer.patch.json +9 -0
- package/overlays/task/overlay.yml +16 -0
- package/overlays/task/setup.sh +29 -0
- package/overlays/task/verify.sh +14 -0
- package/package.json +2 -1
- package/tool/schema/config.schema.json +77 -2
- package/tool/schema/superposition.schema.json +569 -0
|
@@ -0,0 +1,481 @@
|
|
|
1
|
+
# Authoring `superposition.yml`
|
|
2
|
+
|
|
3
|
+
`superposition.yml` (or `.superposition.yml`) is the **canonical input** for all
|
|
4
|
+
container-superposition generation and regeneration flows. Commit it to your repository to
|
|
5
|
+
guarantee reproducible devcontainer builds across your team and CI.
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
- `init` always writes `superposition.yml` as its primary output.
|
|
10
|
+
- `regen` reads only the project file — `superposition.json` is an output-only receipt.
|
|
11
|
+
- `doctor` validates the project file against the last-generated manifest and reports drift.
|
|
12
|
+
- Repos without a project file should run `cs migrate` once to create one from their manifest.
|
|
13
|
+
|
|
14
|
+
## File discovery
|
|
15
|
+
|
|
16
|
+
The tool searches the repository root for `superposition.yml` then `.superposition.yml`. If both
|
|
17
|
+
exist, it fails with an error — keep only one.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Reference
|
|
22
|
+
|
|
23
|
+
### `$schema`
|
|
24
|
+
|
|
25
|
+
```yaml
|
|
26
|
+
$schema: https://raw.githubusercontent.com/veggerby/container-superposition/main/tool/schema/superposition.schema.json
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Optional but recommended. Points editors (VS Code, JetBrains, etc.) to the JSON Schema
|
|
30
|
+
for this file, enabling auto-complete and inline validation. The `init` and `regen`
|
|
31
|
+
commands write this line automatically. The URL above always resolves to the latest
|
|
32
|
+
schema on the `main` branch. A versioned copy is also attached to each
|
|
33
|
+
[GitHub release](https://github.com/veggerby/container-superposition/releases).
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
### `stack`
|
|
38
|
+
|
|
39
|
+
```yaml
|
|
40
|
+
stack: plain # or compose
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
| Value | Description |
|
|
44
|
+
| --------- | --------------------------------------------------- |
|
|
45
|
+
| `plain` | Single-image devcontainer (no Docker Compose) |
|
|
46
|
+
| `compose` | Multi-service devcontainer backed by Docker Compose |
|
|
47
|
+
|
|
48
|
+
Required. Always set this explicitly.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
### `baseImage`
|
|
53
|
+
|
|
54
|
+
```yaml
|
|
55
|
+
baseImage: bookworm # default
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
| Value | Image |
|
|
59
|
+
| ---------- | -------------------------------------------------- |
|
|
60
|
+
| `bookworm` | `mcr.microsoft.com/devcontainers/base:bookworm` ⭐ |
|
|
61
|
+
| `trixie` | `mcr.microsoft.com/devcontainers/base:trixie` |
|
|
62
|
+
| `alpine` | `mcr.microsoft.com/devcontainers/base:alpine` |
|
|
63
|
+
| `ubuntu` | `mcr.microsoft.com/devcontainers/base:ubuntu` |
|
|
64
|
+
| `custom` | Uses `customImage` — see below |
|
|
65
|
+
|
|
66
|
+
---
|
|
67
|
+
|
|
68
|
+
### `customImage`
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
baseImage: custom
|
|
72
|
+
customImage: ghcr.io/myorg/my-base:latest
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Only valid when `baseImage: custom`. Specifies the exact Docker image to use as the base.
|
|
76
|
+
|
|
77
|
+
---
|
|
78
|
+
|
|
79
|
+
### `containerName`
|
|
80
|
+
|
|
81
|
+
```yaml
|
|
82
|
+
containerName: My Project
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Sets the `name` field in `devcontainer.json`. Used by VS Code to label the container.
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
### `overlays`
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
overlays:
|
|
93
|
+
- nodejs
|
|
94
|
+
- postgres
|
|
95
|
+
- grafana
|
|
96
|
+
- docker-sock
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Flat list of overlay IDs to include. This is the **preferred** way to declare overlays.
|
|
100
|
+
Dependency resolution runs automatically: if you select `grafana`, `prometheus` is added
|
|
101
|
+
because it is declared as `requires`.
|
|
102
|
+
|
|
103
|
+
See `docs/overlays.md` for the full overlay catalogue.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### `preset`
|
|
108
|
+
|
|
109
|
+
```yaml
|
|
110
|
+
preset: web-api
|
|
111
|
+
presetChoices:
|
|
112
|
+
language: nodejs
|
|
113
|
+
database: postgres
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Expands a preset (meta-overlay) into a fixed set of overlays. Use `cs list --presets` to
|
|
117
|
+
browse available presets. `presetChoices` passes parameter values to the preset.
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
### `env`
|
|
122
|
+
|
|
123
|
+
Declare runtime environment variables once. The generation pipeline routes them to the correct
|
|
124
|
+
devcontainer artifact based on `stack`.
|
|
125
|
+
|
|
126
|
+
```yaml
|
|
127
|
+
env:
|
|
128
|
+
# String shorthand — target is auto-detected
|
|
129
|
+
APP_NAME: my-app
|
|
130
|
+
|
|
131
|
+
# Long form — explicit routing target
|
|
132
|
+
DB_URL:
|
|
133
|
+
value: postgres://postgres:${POSTGRES_PASSWORD}@postgres:5432/app
|
|
134
|
+
target: auto # default: plain→remoteEnv, compose→docker-compose environment
|
|
135
|
+
DEBUG:
|
|
136
|
+
value: 'true'
|
|
137
|
+
target: remoteEnv # always devcontainer.json remoteEnv
|
|
138
|
+
API_SECRET:
|
|
139
|
+
value: ${API_SECRET}
|
|
140
|
+
target: composeEnv # always docker-compose devcontainer environment (compose only)
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
#### Routing table
|
|
144
|
+
|
|
145
|
+
| `target` | `stack: plain` | `stack: compose` |
|
|
146
|
+
| ---------------- | ----------------------------- | ------------------------------------------------------ |
|
|
147
|
+
| `auto` (default) | `devcontainer.json remoteEnv` | `docker-compose.yml services.devcontainer.environment` |
|
|
148
|
+
| `remoteEnv` | `devcontainer.json remoteEnv` | `devcontainer.json remoteEnv` |
|
|
149
|
+
| `composeEnv` | ❌ Error | `docker-compose.yml services.devcontainer.environment` |
|
|
150
|
+
|
|
151
|
+
#### `${VAR}` references
|
|
152
|
+
|
|
153
|
+
Values can reference variables from the root `.env` file using `${VAR}` or
|
|
154
|
+
`${VAR:-default}` syntax. These are resolved at generation time and written into the
|
|
155
|
+
appropriate output file.
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
### `mounts`
|
|
160
|
+
|
|
161
|
+
Declare filesystem mounts once. All mounts default to `devcontainer.json mounts[]` (`target: auto`).
|
|
162
|
+
Use `composeVolume` to route explicitly to docker-compose volumes on a compose stack.
|
|
163
|
+
|
|
164
|
+
```yaml
|
|
165
|
+
mounts:
|
|
166
|
+
# String shorthand (escape hatch)
|
|
167
|
+
- 'source=${localWorkspaceFolder}/../libs,target=/workspace/libs,type=bind,readonly'
|
|
168
|
+
|
|
169
|
+
# Structured list form (preferred)
|
|
170
|
+
- source: ${HOME}/.codex
|
|
171
|
+
destination: /home/vscode/.codex
|
|
172
|
+
cached: true
|
|
173
|
+
# target: auto (default)
|
|
174
|
+
|
|
175
|
+
# Explicit target override
|
|
176
|
+
- source: certs
|
|
177
|
+
destination: /certs
|
|
178
|
+
type: volume
|
|
179
|
+
target: devcontainerMount
|
|
180
|
+
|
|
181
|
+
# Compose-only target
|
|
182
|
+
- source: ./logs
|
|
183
|
+
destination: /workspace/logs
|
|
184
|
+
target: composeVolume
|
|
185
|
+
|
|
186
|
+
# Raw-value fallback for advanced/custom cases
|
|
187
|
+
- value: './custom-src:/custom-dest:ro'
|
|
188
|
+
target: composeVolume
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
#### Routing table
|
|
192
|
+
|
|
193
|
+
| `target` | `stack: plain` | `stack: compose` |
|
|
194
|
+
| ------------------- | ---------------------------- | ---------------------------------------------------- |
|
|
195
|
+
| `auto` (default) | `devcontainer.json mounts[]` | `devcontainer.json mounts[]` |
|
|
196
|
+
| `devcontainerMount` | `devcontainer.json mounts[]` | `devcontainer.json mounts[]` |
|
|
197
|
+
| `composeVolume` | ❌ Error | `docker-compose.yml services.devcontainer.volumes[]` |
|
|
198
|
+
|
|
199
|
+
Use `devcontainerMount` when you want the same explicit `devcontainer.json mounts[]` routing regardless of stack.
|
|
200
|
+
Use `composeVolume` when you explicitly want compose volume routing.
|
|
201
|
+
|
|
202
|
+
Mounts declared here are applied **before** `customizations.devcontainerPatch` and
|
|
203
|
+
`customizations.dockerComposePatch`, so patch overrides are respected.
|
|
204
|
+
|
|
205
|
+
#### Mount spec formats
|
|
206
|
+
|
|
207
|
+
Structured entries are rendered into the correct target syntax automatically. You can still use
|
|
208
|
+
raw strings (or `value`) when needed:
|
|
209
|
+
|
|
210
|
+
```yaml
|
|
211
|
+
mounts:
|
|
212
|
+
# devcontainer.json style (works with auto/devcontainerMount on any stack)
|
|
213
|
+
- 'source=${localWorkspaceFolder}/../shared,target=/workspace/shared,type=bind'
|
|
214
|
+
|
|
215
|
+
# Docker Compose short syntax (use with composeVolume on a compose stack)
|
|
216
|
+
- value: './local-data:/workspace/data'
|
|
217
|
+
target: composeVolume
|
|
218
|
+
|
|
219
|
+
# Docker named volume (devcontainer style)
|
|
220
|
+
- 'source=my-cache,target=/root/.cache,type=volume'
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
### `shell`
|
|
226
|
+
|
|
227
|
+
Declarative shell profile customizations. This is intended for aliases and shell snippets.
|
|
228
|
+
|
|
229
|
+
Use top-level `env` for environment variables (`export`-style values), not `shell`.
|
|
230
|
+
`shell` is for interactive shell UX (aliases, completions, snippets).
|
|
231
|
+
|
|
232
|
+
```yaml
|
|
233
|
+
shell:
|
|
234
|
+
aliases:
|
|
235
|
+
k: kubectl
|
|
236
|
+
kgp: kubectl get pods
|
|
237
|
+
snippets:
|
|
238
|
+
- source /etc/profile
|
|
239
|
+
# Shell-specific commands must be guarded — shell-init.sh is sourced by
|
|
240
|
+
# both ~/.bashrc and ~/.zshrc, so unguarded bash-only syntax causes errors
|
|
241
|
+
# in zsh and vice versa. Use $BASH_VERSION / $ZSH_VERSION to guard:
|
|
242
|
+
- '[ -n "$BASH_VERSION" ] && complete -C ''/usr/local/bin/aws_completer'' aws'
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
Generation behavior:
|
|
246
|
+
|
|
247
|
+
- Writes `.devcontainer/scripts/shell-init.sh` with aliases/snippets
|
|
248
|
+
- Adds a postCreate hook that idempotently manages a marked block in:
|
|
249
|
+
- `~/.bashrc`
|
|
250
|
+
- `~/.zshrc`
|
|
251
|
+
- The managed block sources the generated `shell-init.sh`
|
|
252
|
+
|
|
253
|
+
> **Note:** `shell-init.sh` is sourced by **both** `~/.bashrc` and `~/.zshrc`.
|
|
254
|
+
> Keep `snippets` shell-agnostic, or guard shell-specific commands with
|
|
255
|
+
> `$BASH_VERSION` / `$ZSH_VERSION` checks (see example above).
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### `customizations`
|
|
260
|
+
|
|
261
|
+
Inline patches applied during generation. These are the same patches that can be placed in
|
|
262
|
+
`.devcontainer/custom/` — `superposition.yml` lets you keep them in the project file instead.
|
|
263
|
+
|
|
264
|
+
```yaml
|
|
265
|
+
customizations:
|
|
266
|
+
devcontainerPatch:
|
|
267
|
+
features:
|
|
268
|
+
ghcr.io/devcontainers-extra/features/apt-get-packages:1:
|
|
269
|
+
packages: jq curl
|
|
270
|
+
customizations:
|
|
271
|
+
vscode:
|
|
272
|
+
extensions:
|
|
273
|
+
- eamodio.gitlens
|
|
274
|
+
|
|
275
|
+
dockerComposePatch:
|
|
276
|
+
services:
|
|
277
|
+
devcontainer:
|
|
278
|
+
extra_hosts:
|
|
279
|
+
- 'host.docker.internal:host-gateway'
|
|
280
|
+
|
|
281
|
+
envTemplate:
|
|
282
|
+
POSTGRES_PASSWORD: postgres
|
|
283
|
+
MY_API_KEY: changeme
|
|
284
|
+
|
|
285
|
+
scripts:
|
|
286
|
+
postCreate:
|
|
287
|
+
- npm install
|
|
288
|
+
- npx prisma migrate dev
|
|
289
|
+
postStart:
|
|
290
|
+
- pg_isready -h postgres || true
|
|
291
|
+
|
|
292
|
+
files:
|
|
293
|
+
- path: config/app.yml
|
|
294
|
+
content: |
|
|
295
|
+
database:
|
|
296
|
+
host: postgres
|
|
297
|
+
port: 5432
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
#### Application order
|
|
301
|
+
|
|
302
|
+
1. Base template loaded
|
|
303
|
+
2. Overlays applied in order
|
|
304
|
+
3. Port offsets applied
|
|
305
|
+
4. Project `env` applied
|
|
306
|
+
5. Project `mounts` applied
|
|
307
|
+
6. `customizations.devcontainerPatch` merged (deepMerge, arrays deduplicated)
|
|
308
|
+
7. `customizations.dockerComposePatch` merged
|
|
309
|
+
8. Target-specific patches applied
|
|
310
|
+
9. Files written
|
|
311
|
+
|
|
312
|
+
---
|
|
313
|
+
|
|
314
|
+
### `portOffset`
|
|
315
|
+
|
|
316
|
+
```yaml
|
|
317
|
+
portOffset: 100
|
|
318
|
+
```
|
|
319
|
+
|
|
320
|
+
Shifts all overlay-declared host ports by the given integer. Useful when running multiple
|
|
321
|
+
instances of the same stack on one machine (e.g. feature branches in parallel).
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
### `outputPath`
|
|
326
|
+
|
|
327
|
+
```yaml
|
|
328
|
+
outputPath: ./.devcontainer
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
Where to write the generated devcontainer files. Default: `./.devcontainer`.
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
### `target`
|
|
336
|
+
|
|
337
|
+
```yaml
|
|
338
|
+
target: codespaces # local | codespaces | gitpod | devpod
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Selects a deployment-target profile that applies environment-specific patches.
|
|
342
|
+
|
|
343
|
+
See [deployment-targets.md](deployment-targets.md) for details.
|
|
344
|
+
|
|
345
|
+
---
|
|
346
|
+
|
|
347
|
+
### `minimal`
|
|
348
|
+
|
|
349
|
+
```yaml
|
|
350
|
+
minimal: true
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
When `true`, overlays marked with `minimal: true` in their `overlay.yml` are excluded. Useful
|
|
354
|
+
for CI environments where extra tooling is unnecessary.
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
### `editor`
|
|
359
|
+
|
|
360
|
+
```yaml
|
|
361
|
+
editor: vscode # vscode | jetbrains | none
|
|
362
|
+
```
|
|
363
|
+
|
|
364
|
+
Selects the editor customization profile:
|
|
365
|
+
|
|
366
|
+
| Value | Effect |
|
|
367
|
+
| ----------- | ---------------------------------------------------------------------------- |
|
|
368
|
+
| `vscode` | Include VS Code extensions and settings from all selected overlays (default) |
|
|
369
|
+
| `jetbrains` | Remove VS Code customizations; add `customizations.jetbrains` block |
|
|
370
|
+
| `none` | Remove VS Code customizations entirely |
|
|
371
|
+
|
|
372
|
+
---
|
|
373
|
+
|
|
374
|
+
### `parameters`
|
|
375
|
+
|
|
376
|
+
```yaml
|
|
377
|
+
parameters:
|
|
378
|
+
POSTGRES_VERSION: '16'
|
|
379
|
+
POSTGRES_PORT: '5433'
|
|
380
|
+
REDIS_PASSWORD: mysecret
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
Overlay parameter values. Keys correspond to parameter names declared in `overlay.yml`
|
|
384
|
+
`parameters:` sections. Values are substituted for `{{cs.KEY}}` tokens throughout generated
|
|
385
|
+
files.
|
|
386
|
+
|
|
387
|
+
---
|
|
388
|
+
|
|
389
|
+
## Complete example
|
|
390
|
+
|
|
391
|
+
```yaml
|
|
392
|
+
stack: compose
|
|
393
|
+
baseImage: bookworm
|
|
394
|
+
containerName: My Web API
|
|
395
|
+
|
|
396
|
+
overlays:
|
|
397
|
+
- nodejs
|
|
398
|
+
- postgres
|
|
399
|
+
- redis
|
|
400
|
+
- grafana
|
|
401
|
+
|
|
402
|
+
env:
|
|
403
|
+
APP_ENV: development
|
|
404
|
+
NODE_ENV: development
|
|
405
|
+
DATABASE_URL:
|
|
406
|
+
value: 'postgres://postgres:${POSTGRES_PASSWORD:-postgres}@postgres:5432/app'
|
|
407
|
+
target: composeEnv
|
|
408
|
+
|
|
409
|
+
mounts:
|
|
410
|
+
# Bind-mount shared workspace tools (plain and compose auto-routing)
|
|
411
|
+
- 'source=${localWorkspaceFolder}/../tools,target=/workspace/tools,type=bind,readonly'
|
|
412
|
+
# Always inject local SSL certificates into devcontainer.json
|
|
413
|
+
- value: 'source=${localWorkspaceFolder}/.certs,target=/usr/local/share/ca-certificates,type=bind,readonly'
|
|
414
|
+
target: devcontainerMount
|
|
415
|
+
|
|
416
|
+
portOffset: 0
|
|
417
|
+
|
|
418
|
+
target: local
|
|
419
|
+
|
|
420
|
+
customizations:
|
|
421
|
+
envTemplate:
|
|
422
|
+
POSTGRES_PASSWORD: postgres
|
|
423
|
+
REDIS_PASSWORD: ''
|
|
424
|
+
devcontainerPatch:
|
|
425
|
+
features:
|
|
426
|
+
ghcr.io/devcontainers-extra/features/apt-get-packages:1:
|
|
427
|
+
packages: jq httpie
|
|
428
|
+
scripts:
|
|
429
|
+
postCreate:
|
|
430
|
+
- npm install
|
|
431
|
+
postStart:
|
|
432
|
+
- pg_isready -h postgres -U postgres || true
|
|
433
|
+
|
|
434
|
+
parameters:
|
|
435
|
+
POSTGRES_VERSION: '16'
|
|
436
|
+
REDIS_PORT: '6379'
|
|
437
|
+
```
|
|
438
|
+
|
|
439
|
+
---
|
|
440
|
+
|
|
441
|
+
## Legacy fields (deprecated)
|
|
442
|
+
|
|
443
|
+
These category arrays are accepted for backward compatibility but `overlays:` is preferred:
|
|
444
|
+
|
|
445
|
+
```yaml
|
|
446
|
+
# Deprecated — use overlays: [nodejs, python] instead
|
|
447
|
+
language:
|
|
448
|
+
- nodejs
|
|
449
|
+
- python
|
|
450
|
+
|
|
451
|
+
# Deprecated — use overlays: [postgres, redis] instead
|
|
452
|
+
database:
|
|
453
|
+
- postgres
|
|
454
|
+
- redis
|
|
455
|
+
|
|
456
|
+
# Deprecated — use overlays: [playwright] instead
|
|
457
|
+
playwright: true
|
|
458
|
+
|
|
459
|
+
# Deprecated — use overlays: [azure-cli] instead
|
|
460
|
+
cloudTools:
|
|
461
|
+
- azure-cli
|
|
462
|
+
|
|
463
|
+
# Deprecated — use overlays: [docker-in-docker] instead
|
|
464
|
+
devTools:
|
|
465
|
+
- docker-in-docker
|
|
466
|
+
|
|
467
|
+
# Deprecated — use overlays: [prometheus] instead
|
|
468
|
+
observability:
|
|
469
|
+
- prometheus
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
---
|
|
473
|
+
|
|
474
|
+
## See also
|
|
475
|
+
|
|
476
|
+
- [Overlays catalogue](overlays.md)
|
|
477
|
+
- [Custom patches](custom-patches.md)
|
|
478
|
+
- [Deployment targets](deployment-targets.md)
|
|
479
|
+
- [Presets](presets.md)
|
|
480
|
+
- [Merge strategy](merge-strategy.md)
|
|
481
|
+
- [Workflows and regen](workflows.md)
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
# Ansible Overlay
|
|
2
|
+
|
|
3
|
+
Adds [Ansible](https://www.ansible.com/) tooling for automation, configuration management, and infrastructure provisioning workflows inside your devcontainer.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Ansible CLI** — `ansible`, `ansible-playbook`, `ansible-galaxy`, `ansible-vault`, `ansible-doc`
|
|
8
|
+
- **ansible-lint** — Best-practice and style checks for playbooks, roles, and collections
|
|
9
|
+
- **VS Code Extension:** Red Hat Ansible (`redhat.ansible`) — syntax highlighting, autocomplete, and validation powered by the Ansible Language Server
|
|
10
|
+
|
|
11
|
+
## How It Works
|
|
12
|
+
|
|
13
|
+
Ansible and ansible-lint are installed via the shared `cross-distro-packages` feature during devcontainer creation:
|
|
14
|
+
|
|
15
|
+
- **Debian/Ubuntu**: installs `ansible` (or `ansible-core`) and `ansible-lint` (or `python3-ansible-lint`) via `apt`
|
|
16
|
+
- **Alpine**: installs `ansible` and `ansible-lint` via `apk`
|
|
17
|
+
|
|
18
|
+
No extra services are started — Ansible runs entirely inside the devcontainer and connects to remote hosts (or `localhost`) over SSH or WinRM.
|
|
19
|
+
|
|
20
|
+
**Dependencies:** None required. Combine with cloud CLI overlays (`aws-cli`, `azure-cli`, `gcloud`) for cloud target automation, or `terraform` for hybrid IaC workflows.
|
|
21
|
+
|
|
22
|
+
## Common Commands
|
|
23
|
+
|
|
24
|
+
### Inventory & Connectivity
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Ping all hosts in the default inventory
|
|
28
|
+
ansible all -m ping
|
|
29
|
+
|
|
30
|
+
# Ping using an explicit inventory file
|
|
31
|
+
ansible all -i inventory/hosts.ini -m ping
|
|
32
|
+
|
|
33
|
+
# Gather facts from a host group
|
|
34
|
+
ansible webservers -m gather_facts -i inventory/hosts.ini
|
|
35
|
+
|
|
36
|
+
# List all hosts in an inventory
|
|
37
|
+
ansible-inventory -i inventory/hosts.ini --list
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Running Playbooks
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Run a playbook against all hosts in inventory
|
|
44
|
+
ansible-playbook playbook.yml
|
|
45
|
+
|
|
46
|
+
# Run with an explicit inventory
|
|
47
|
+
ansible-playbook -i inventory/hosts.ini playbook.yml
|
|
48
|
+
|
|
49
|
+
# Run with extra variables
|
|
50
|
+
ansible-playbook playbook.yml -e "env=production db_host=db.example.com"
|
|
51
|
+
|
|
52
|
+
# Limit execution to a specific host group
|
|
53
|
+
ansible-playbook playbook.yml --limit webservers
|
|
54
|
+
|
|
55
|
+
# Dry-run (check mode) — show changes without applying them
|
|
56
|
+
ansible-playbook playbook.yml --check
|
|
57
|
+
|
|
58
|
+
# Verbose output for debugging
|
|
59
|
+
ansible-playbook playbook.yml -vvv
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Ansible Galaxy
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
# Install a collection from Galaxy
|
|
66
|
+
ansible-galaxy collection install community.general
|
|
67
|
+
|
|
68
|
+
# Install a role from Galaxy
|
|
69
|
+
ansible-galaxy role install geerlingguy.nginx
|
|
70
|
+
|
|
71
|
+
# Install from a requirements file
|
|
72
|
+
ansible-galaxy install -r requirements.yml
|
|
73
|
+
|
|
74
|
+
# List installed collections
|
|
75
|
+
ansible-galaxy collection list
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Vault (Secrets Management)
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
# Encrypt a file
|
|
82
|
+
ansible-vault encrypt secrets.yml
|
|
83
|
+
|
|
84
|
+
# Decrypt a file
|
|
85
|
+
ansible-vault decrypt secrets.yml
|
|
86
|
+
|
|
87
|
+
# View an encrypted file without decrypting on disk
|
|
88
|
+
ansible-vault view secrets.yml
|
|
89
|
+
|
|
90
|
+
# Edit an encrypted file in place
|
|
91
|
+
ansible-vault edit secrets.yml
|
|
92
|
+
|
|
93
|
+
# Run a playbook with an encrypted vault
|
|
94
|
+
ansible-playbook playbook.yml --ask-vault-pass
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Linting
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# Lint a playbook
|
|
101
|
+
ansible-lint playbook.yml
|
|
102
|
+
|
|
103
|
+
# Lint all playbooks and roles in the current project
|
|
104
|
+
ansible-lint
|
|
105
|
+
|
|
106
|
+
# Show lint violations with profile info
|
|
107
|
+
ansible-lint --profile production playbook.yml
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Quick Start
|
|
111
|
+
|
|
112
|
+
Create a minimal localhost playbook:
|
|
113
|
+
|
|
114
|
+
```yaml
|
|
115
|
+
# playbook.yml
|
|
116
|
+
- name: Local test
|
|
117
|
+
hosts: localhost
|
|
118
|
+
connection: local
|
|
119
|
+
gather_facts: false
|
|
120
|
+
tasks:
|
|
121
|
+
- name: Ping localhost
|
|
122
|
+
ansible.builtin.ping:
|
|
123
|
+
|
|
124
|
+
- name: Print a message
|
|
125
|
+
ansible.builtin.debug:
|
|
126
|
+
msg: 'Ansible is working!'
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
Run and lint it:
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
ansible-playbook playbook.yml
|
|
133
|
+
ansible-lint playbook.yml
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## Use Cases
|
|
137
|
+
|
|
138
|
+
- **Configuration management** — Enforce consistent state across servers (packages, files, services, users)
|
|
139
|
+
- **Application deployment** — Orchestrate multi-step deployments to remote hosts or cloud VMs
|
|
140
|
+
- **Cloud provisioning** — Combine with cloud modules (`amazon.aws`, `azure.azcollection`, `google.cloud`) to provision infrastructure
|
|
141
|
+
- **Kubernetes automation** — Use the `kubernetes.core` collection to manage cluster resources
|
|
142
|
+
- **Local development automation** — Run playbooks against `localhost` to set up or reset dev environments
|
|
143
|
+
|
|
144
|
+
**Integrates well with:**
|
|
145
|
+
|
|
146
|
+
- `aws-cli`, `azure-cli`, `gcloud` — cloud target automation via provider-specific modules
|
|
147
|
+
- `terraform` — use Terraform for infra provisioning, Ansible for configuration of provisioned resources
|
|
148
|
+
- `kubectl-helm` — manage Kubernetes workloads with the `kubernetes.core` Ansible collection
|
|
149
|
+
|
|
150
|
+
## References
|
|
151
|
+
|
|
152
|
+
- [Ansible Documentation](https://docs.ansible.com/)
|
|
153
|
+
- [ansible-lint Documentation](https://ansible.readthedocs.io/projects/lint/)
|
|
154
|
+
- [Ansible Galaxy](https://galaxy.ansible.com/)
|
|
155
|
+
- [Red Hat Ansible VS Code Extension](https://marketplace.visualstudio.com/items?itemName=redhat.ansible)
|
|
156
|
+
- [Ansible Collections Index](https://docs.ansible.com/ansible/latest/collections/index.html)
|
|
157
|
+
|
|
158
|
+
**Related Overlays:**
|
|
159
|
+
|
|
160
|
+
- [`aws-cli`](../aws-cli/README.md) — AWS CLI for cloud target automation
|
|
161
|
+
- [`azure-cli`](../azure-cli/README.md) — Azure CLI for cloud target automation
|
|
162
|
+
- [`gcloud`](../gcloud/README.md) — Google Cloud SDK for cloud target automation
|
|
163
|
+
- [`terraform`](../terraform/README.md) — Infrastructure provisioning to pair with Ansible configuration management
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://raw.githubusercontent.com/devcontainers/spec/main/schemas/devContainer.base.schema.json",
|
|
3
|
+
"features": {
|
|
4
|
+
"./features/cross-distro-packages": {
|
|
5
|
+
"apt": "ansible|ansible-core ansible-lint|python3-ansible-lint",
|
|
6
|
+
"apk": "ansible ansible-lint"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"customizations": {
|
|
10
|
+
"vscode": {
|
|
11
|
+
"extensions": ["redhat.ansible"]
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
id: ansible
|
|
2
|
+
name: Ansible
|
|
3
|
+
description: Automation and configuration management with Ansible and ansible-lint
|
|
4
|
+
category: cloud
|
|
5
|
+
supports: []
|
|
6
|
+
requires: []
|
|
7
|
+
suggests:
|
|
8
|
+
- aws-cli
|
|
9
|
+
- azure-cli
|
|
10
|
+
- gcloud
|
|
11
|
+
- terraform
|
|
12
|
+
conflicts: []
|
|
13
|
+
tags:
|
|
14
|
+
- cloud
|
|
15
|
+
- iac
|
|
16
|
+
- automation
|
|
17
|
+
- ansible
|
|
18
|
+
ports: []
|