mirror of
https://github.com/fscotto/infra.git
synced 2026-11-25 21:29:51 +00:00
Deploy devcontainer generator to user local bin with Ansible
This commit is contained in:
@@ -612,3 +612,8 @@ validated exports of older historical data will use a dedicated Atlas NFS datase
|
|||||||
- Focused validation: `go -C cmd/devcontainer test ./...`.
|
- Focused validation: `go -C cmd/devcontainer test ./...`.
|
||||||
- Real engine builds, host credential forwarding and Fedora SELinux/Podman checks
|
- Real engine builds, host credential forwarding and Fedora SELinux/Podman checks
|
||||||
require target-host validation; do not report generator tests as runtime evidence.
|
require target-host validation; do not report generator tests as runtime evidence.
|
||||||
|
|
||||||
|
- `devcontainer_generator` builds the CLI natively on Fedora graphical desktops
|
||||||
|
and development workstations and installs it in `~/.local/bin/devcontainer`.
|
||||||
|
Validate with `ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator --check --diff`;
|
||||||
|
check mode skips compilation and binary installation explicitly.
|
||||||
|
|||||||
@@ -900,3 +900,6 @@ Generate a reusable language environment for an existing project with
|
|||||||
`devcontainer ~/src/project --language python --agents codex,cline`.
|
`devcontainer ~/src/project --language python --agents codex,cline`.
|
||||||
Git and selected coding-agent configuration are shared from the development host.
|
Git and selected coding-agent configuration are shared from the development host.
|
||||||
See [profiles, host requirements and validation](docs/project-devcontainers.md).
|
See [profiles, host requirements and validation](docs/project-devcontainers.md).
|
||||||
|
|
||||||
|
Deploy `~/.local/bin/devcontainer` on a Fedora desktop/workstation with
|
||||||
|
`ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator -K`.
|
||||||
|
|||||||
4
ansible/roles/devcontainer_generator/defaults/main.yml
Normal file
4
ansible/roles/devcontainer_generator/defaults/main.yml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
devcontainer_generator_go_binary: /usr/bin/go
|
||||||
|
devcontainer_generator_install_go: true
|
||||||
|
devcontainer_generator_build_dir: "{{ user_home }}/.cache/infra/devcontainer-generator"
|
||||||
64
ansible/roles/devcontainer_generator/tasks/main.yml
Normal file
64
ansible/roles/devcontainer_generator/tasks/main.yml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
---
|
||||||
|
- name: Install Go compiler for the devcontainer generator
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name: golang
|
||||||
|
state: present
|
||||||
|
when: devcontainer_generator_install_go | bool
|
||||||
|
|
||||||
|
- name: Ensure devcontainer generator directories exist
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: directory
|
||||||
|
owner: "{{ username }}"
|
||||||
|
group: "{{ user_group }}"
|
||||||
|
mode: "0755"
|
||||||
|
loop:
|
||||||
|
- "{{ user_home }}/.local/bin"
|
||||||
|
- "{{ devcontainer_generator_build_dir }}"
|
||||||
|
|
||||||
|
- name: Copy devcontainer generator sources
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ playbook_dir }}/../cmd/devcontainer/"
|
||||||
|
dest: "{{ devcontainer_generator_build_dir }}/src/"
|
||||||
|
owner: "{{ username }}"
|
||||||
|
group: "{{ user_group }}"
|
||||||
|
mode: preserve
|
||||||
|
|
||||||
|
- name: Build devcontainer generator for the target host
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- "{{ devcontainer_generator_go_binary }}"
|
||||||
|
- build
|
||||||
|
- -trimpath
|
||||||
|
- -buildvcs=false
|
||||||
|
- -o
|
||||||
|
- "{{ devcontainer_generator_build_dir }}/devcontainer"
|
||||||
|
- .
|
||||||
|
chdir: "{{ devcontainer_generator_build_dir }}/src"
|
||||||
|
become_user: "{{ username }}"
|
||||||
|
environment:
|
||||||
|
GOCACHE: "{{ devcontainer_generator_build_dir }}/go-cache"
|
||||||
|
GOTOOLCHAIN: local
|
||||||
|
GOPROXY: "off"
|
||||||
|
GOSUMDB: "off"
|
||||||
|
CGO_ENABLED: "0"
|
||||||
|
# Compilation refreshes a cached artifact; copy below reports installation changes.
|
||||||
|
changed_when: false
|
||||||
|
when: not ansible_check_mode
|
||||||
|
|
||||||
|
- name: Install devcontainer generator in the user PATH
|
||||||
|
ansible.builtin.copy:
|
||||||
|
src: "{{ devcontainer_generator_build_dir }}/devcontainer"
|
||||||
|
remote_src: true
|
||||||
|
dest: "{{ user_home }}/.local/bin/devcontainer"
|
||||||
|
owner: "{{ username }}"
|
||||||
|
group: "{{ user_group }}"
|
||||||
|
mode: "0755"
|
||||||
|
when: not ansible_check_mode
|
||||||
|
|
||||||
|
- name: Explain devcontainer generator check-mode behavior
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg: >-
|
||||||
|
Check mode validates package and source deployment only. Compilation and
|
||||||
|
installation of {{ user_home }}/.local/bin/devcontainer require a normal run.
|
||||||
|
when: ansible_check_mode
|
||||||
@@ -152,3 +152,12 @@
|
|||||||
|
|
||||||
roles:
|
roles:
|
||||||
- profile_workstation_dev_wsl
|
- profile_workstation_dev_wsl
|
||||||
|
|
||||||
|
- name: Deploy project devcontainer generator
|
||||||
|
hosts: platform_fedora
|
||||||
|
become: true
|
||||||
|
tags: [devcontainer_generator]
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- role: devcontainer_generator
|
||||||
|
when: "'graphical_desktop' in group_names or 'workstation_dev_fedora' in group_names"
|
||||||
|
|||||||
@@ -17,6 +17,28 @@ devcontainer ~/src/my-project --language python --agents codex,cline
|
|||||||
devcontainer ~/src/my-project --language c-cpp --agents none
|
devcontainer ~/src/my-project --language c-cpp --agents none
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Ansible deployment
|
||||||
|
|
||||||
|
On ikaros, nymph or deadalus, from the local `infra` checkout:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator -K
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace the limit with `nymph` or `deadalus` as appropriate. The task installs
|
||||||
|
Fedora's Go compiler, copies the sources into the user's build cache, compiles
|
||||||
|
natively without downloading Go modules, and installs `~/.local/bin/devcontainer`
|
||||||
|
with mode `0755`. Subsequent runs update the executable only when its contents
|
||||||
|
change. Rebuilds use the Go cache. The role targets Fedora graphical desktops
|
||||||
|
and Fedora development workstations; it does not start any containers.
|
||||||
|
|
||||||
|
Check mode validates packages and source deployment but skips compilation and
|
||||||
|
binary installation, and reports that limitation explicitly:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator --check --diff
|
||||||
|
```
|
||||||
|
|
||||||
Profiles: `c-cpp`, `go`, `rust`, `python`, `node`, `java`, `infra`. They generate
|
Profiles: `c-cpp`, `go`, `rust`, `python`, `node`, `java`, `infra`. They generate
|
||||||
`.devcontainer/devcontainer.json` and `Dockerfile`. Open the project in local VS
|
`.devcontainer/devcontainer.json` and `Dockerfile`. Open the project in local VS
|
||||||
Code (in Fedora WSL on deadalus) and choose **Reopen in Container**. The generator
|
Code (in Fedora WSL on deadalus) and choose **Reopen in Container**. The generator
|
||||||
|
|||||||
Reference in New Issue
Block a user