Files
a13labs.infra/ansible/roles/macos_dev_station/tasks/mcp_installers.yml
T
alexandre.pires 040f7a382f Add macOS development station playbook and role
- Created a new Ansible playbook for configuring macOS development stations.
- Added role `macos_dev_station` with default variables, handlers, and tasks.
- Implemented tasks for installing Homebrew packages, managing user configurations, and setting up launch agents for code-server and opencode.
- Included templates for launchd plist files and startup scripts for code-server and opencode.
- Added validation for required environment variables and configurations.
- Updated inventory to include macOS hosts and added a setup script for initial prerequisites.
- Modified Terraform configuration to include DNS records for new services.
2026-07-04 15:37:35 +02:00

133 lines
4.5 KiB
YAML

---
- name: Ensure MCP installer definitions list is valid
ansible.builtin.assert:
that:
- macos_dev_station_mcp_installers is iterable
fail_msg: "macos_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: "{{ macos_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: "{{ macos_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: "{{ macos_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: "{{ macos_dev_station_mcp_installers }}"
when:
- item.enabled | default(true) | bool
- item.kind == 'go'
- name: Discover npm executable path for MCP installers
ansible.builtin.command: /bin/sh -lc "command -v npm"
register: __macos_mcp_npm_path
changed_when: false
failed_when: __macos_mcp_npm_path.rc != 0
environment:
PATH: "{{ macos_dev_station_path }}"
when: (macos_dev_station_mcp_installers | selectattr('kind', 'equalto', 'npm') | list | length) > 0
- name: Install npm MCP packages for service user
become: true
become_user: "{{ macos_dev_station_service_user }}"
ansible.builtin.command:
argv:
- "{{ __macos_mcp_npm_path.stdout | trim }}"
- install
- --prefix
- "{{ macos_dev_station_service_home }}/.local"
- --global
- "{{ item.package }}@{{ item.version | default('latest') }}"
args:
creates: "{{ macos_dev_station_service_home }}/.local/lib/node_modules/{{ item.package }}"
register: __mcp_npm_install
changed_when: __mcp_npm_install.rc == 0
environment:
HOME: "{{ macos_dev_station_service_home }}"
USER: "{{ macos_dev_station_service_user }}"
PATH: "{{ macos_dev_station_path }}"
notify: Restart opencode launch agent
loop: "{{ macos_dev_station_mcp_installers }}"
when:
- item.enabled | default(true) | bool
- item.kind == 'npm'
- name: Install uv MCP tools for service user
become: true
become_user: "{{ macos_dev_station_service_user }}"
ansible.builtin.command:
argv:
- uv
- tool
- install
- "{{ item.package }}@{{ item.version | default('latest') }}"
args:
creates: "{{ macos_dev_station_service_home }}/.local/bin/{{ item.binary }}"
register: __mcp_uv_install
changed_when: __mcp_uv_install.rc == 0
environment:
HOME: "{{ macos_dev_station_service_home }}"
USER: "{{ macos_dev_station_service_user }}"
PATH: "{{ macos_dev_station_path }}"
notify: Restart opencode launch agent
loop: "{{ macos_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: "{{ macos_dev_station_service_user }}"
ansible.builtin.command:
argv:
- go
- install
- "{{ item.module }}@{{ item.version | default('latest') }}"
args:
creates: "{{ macos_dev_station_service_home }}/.local/bin/{{ item.binary }}"
register: __mcp_go_install
changed_when: __mcp_go_install.rc == 0
environment:
HOME: "{{ macos_dev_station_service_home }}"
USER: "{{ macos_dev_station_service_user }}"
PATH: "{{ macos_dev_station_path }}"
GOBIN: "{{ macos_dev_station_service_home }}/.local/bin"
notify: Restart opencode launch agent
loop: "{{ macos_dev_station_mcp_installers }}"
when:
- item.enabled | default(true) | bool
- item.kind == 'go'