Files
a13labs.infra/ansible/roles/linux_dev_station/tasks/mcp_installers.yml
T
alexandre.pires 59b2c10c43 Add Linux development station role with systemd services for code-server and OpenCode
- Implemented handlers for restarting code-server and OpenCode services.
- Created main tasks for setting up a Linux development station, including user management, package installation, and configuration.
- Added validation for OpenCode server credentials and code-server password.
- Introduced tool package management for npm, uv, and go installers.
- Developed templates for systemd service units for code-server and OpenCode.
- Included scripts for starting code-server and OpenCode with SSH agent support.
- Updated inventory and Terraform configuration to include new development host.
2026-07-10 15:44:18 +02:00

139 lines
4.7 KiB
YAML

---
- name: Ensure MCP installer definitions list is valid
ansible.builtin.assert:
that:
- linux_dev_station_mcp_installers is iterable
fail_msg: "linux_dev_station_mcp_installers must be a list of installer definitions."
- name: Validate MCP installer kind values
ansible.builtin.assert:
that:
- item.kind is defined
- item.kind in ['npm', 'uv', 'go']
fail_msg: >-
MCP installer '{{ item.name | default('unnamed') }}'
has unsupported kind '{{ item.kind | default('undefined') }}'.
Supported: npm, uv, go.
loop: "{{ linux_dev_station_mcp_installers }}"
when: item.enabled | default(true) | bool
- name: Validate npm MCP installers
ansible.builtin.assert:
that:
- item.package is defined
- item.package | length > 0
fail_msg: "npm MCP installer '{{ item.name | default('unnamed') }}' requires 'package'."
loop: "{{ linux_dev_station_mcp_installers }}"
when:
- item.enabled | default(true) | bool
- item.kind == 'npm'
- name: Validate uv MCP installers
ansible.builtin.assert:
that:
- item.package is defined
- item.package | length > 0
- item.binary is defined
- item.binary | length > 0
fail_msg: "uv MCP installer '{{ item.name | default('unnamed') }}' requires 'package' and 'binary'."
loop: "{{ linux_dev_station_mcp_installers }}"
when:
- item.enabled | default(true) | bool
- item.kind == 'uv'
- name: Validate go MCP installers
ansible.builtin.assert:
that:
- item.module is defined
- item.module | length > 0
- item.binary is defined
- item.binary | length > 0
fail_msg: "go MCP installer '{{ item.name | default('unnamed') }}' requires 'module' and 'binary'."
loop: "{{ linux_dev_station_mcp_installers }}"
when:
- item.enabled | default(true) | bool
- item.kind == 'go'
- name: Discover npm executable path for MCP installers
become: true
become_user: "{{ linux_dev_station_service_user }}"
ansible.builtin.command: /bin/sh -lc "command -v npm"
register: __linux_dev_station_mcp_npm_path
changed_when: false
failed_when: false
environment:
PATH: "{{ linux_dev_station_path }}"
when: (linux_dev_station_mcp_installers | selectattr('kind', 'equalto', 'npm') | list | length) > 0
- name: Install npm MCP packages for service user
become: true
become_user: "{{ linux_dev_station_service_user }}"
ansible.builtin.command:
argv:
- "{{ __linux_dev_station_mcp_npm_path.stdout | trim }}"
- install
- --prefix
- "{{ linux_dev_station_service_home }}/.local"
- --global
- "{{ item.package }}@{{ item.version | default('latest') }}"
args:
creates: "{{ linux_dev_station_service_home }}/.local/lib/node_modules/{{ item.package }}"
register: __linux_dev_station_mcp_npm_install
changed_when: __linux_dev_station_mcp_npm_install.rc == 0
environment:
HOME: "{{ linux_dev_station_service_home }}"
USER: "{{ linux_dev_station_service_user }}"
PATH: "{{ linux_dev_station_path }}"
notify: Restart opencode
loop: "{{ linux_dev_station_mcp_installers }}"
when:
- item.enabled | default(true) | bool
- item.kind == 'npm'
- __linux_dev_station_mcp_npm_path.rc | default(1) == 0
- name: Install uv MCP tools for service user
become: true
become_user: "{{ linux_dev_station_service_user }}"
ansible.builtin.command:
argv:
- uv
- tool
- install
- "{{ item.package }}@{{ item.version | default('latest') }}"
args:
creates: "{{ linux_dev_station_service_home }}/.local/bin/{{ item.binary }}"
register: __linux_dev_station_mcp_uv_install
changed_when: __linux_dev_station_mcp_uv_install.rc == 0
environment:
HOME: "{{ linux_dev_station_service_home }}"
USER: "{{ linux_dev_station_service_user }}"
PATH: "{{ linux_dev_station_path }}"
notify: Restart opencode
loop: "{{ linux_dev_station_mcp_installers }}"
when:
- item.enabled | default(true) | bool
- item.kind == 'uv'
- name: Install go MCP binaries for service user
become: true
become_user: "{{ linux_dev_station_service_user }}"
ansible.builtin.command:
argv:
- go
- install
- "{{ item.module }}@{{ item.version | default('latest') }}"
args:
creates: "{{ linux_dev_station_service_home }}/.local/bin/{{ item.binary }}"
register: __linux_dev_station_mcp_go_install
changed_when: __linux_dev_station_mcp_go_install.rc == 0
environment:
HOME: "{{ linux_dev_station_service_home }}"
USER: "{{ linux_dev_station_service_user }}"
PATH: "{{ linux_dev_station_path }}"
GOBIN: "{{ linux_dev_station_service_home }}/.local/bin"
notify: Restart opencode
loop: "{{ linux_dev_station_mcp_installers }}"
when:
- item.enabled | default(true) | bool
- item.kind == 'go'