Files
infra/ansible/roles/profile_workstation_dev_wsl/tasks/main.yml
Fabio Scotto di Santolo 295f1a62ad Handle Maven on Mise
2026-09-04 09:36:01 +02:00

120 lines
3.7 KiB
YAML

---
- name: Ensure Windows Emacs authoring directories exist
tags: [dotfiles, dotfiles:workstation, emacs, wsl]
ansible.builtin.file:
path: "{{ workstation_wsl_windows_user_home }}/{{ item }}"
state: directory
become_user: "{{ username }}"
loop:
- Org
- Org/documentation
- Org/meetings
- Org/projects
when: emacs_enabled | default(false) | bool
- name: Deploy shared Emacs configuration to the Windows home
tags: [dotfiles, dotfiles:workstation, emacs, wsl]
ansible.builtin.copy:
src: "{{ playbook_dir }}/../dotfiles/desktop/.emacs.d/"
dest: "{{ workstation_wsl_windows_user_home }}/.emacs.d/"
mode: preserve
become_user: "{{ username }}"
when: emacs_enabled | default(false) | bool
- name: Deploy Org HTML stylesheet to the Windows home
tags: [dotfiles, dotfiles:workstation, emacs, wsl]
ansible.builtin.copy:
src: "{{ playbook_dir }}/../dotfiles/desktop/.emacs.d/templates/org/org.css"
dest: "{{ workstation_wsl_windows_user_home }}/Org/org.css"
mode: "0644"
become_user: "{{ username }}"
when: emacs_enabled | default(false) | bool
- name: Ensure WSL tmux directories exist
tags: [dotfiles, dotfiles:workstation, tmux, wsl]
ansible.builtin.file:
path: "{{ user_home }}/{{ item }}"
state: directory
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0755"
loop:
- .tmux
- .tmux/bin
- .tmux/plugins
- name: Copy workstation WSL dotfiles
tags: [dotfiles, dotfiles:workstation, wsl]
ansible.builtin.copy:
src: "{{ playbook_dir }}/../dotfiles/{{ item.source_dir | default('workstation_dev_wsl') }}/{{ item.src }}"
dest: "{{ user_home }}/{{ item.dest }}"
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "{{ item.mode }}"
loop: "{{ workstation_dev_wsl_dotfiles | default([]) }}"
loop_control:
label: "{{ item.dest }}"
- name: Check whether the pinned Java version is installed with Mise
tags: [packages, mise, java, wsl]
ansible.builtin.command:
cmd: "mise where java@{{ workstation_mise_java_version }}"
become_user: "{{ username }}"
environment:
HOME: "{{ user_home }}"
register: workstation_mise_java_where
changed_when: false
failed_when: false
- name: Check whether the pinned Maven version is installed with Mise
tags: [packages, mise, maven, wsl]
ansible.builtin.command:
cmd: "mise where maven@{{ workstation_mise_maven_version }}"
become_user: "{{ username }}"
environment:
HOME: "{{ user_home }}"
register: workstation_mise_maven_where
changed_when: false
failed_when: false
- name: Install the pinned Mise tools
tags: [packages, mise, java, maven, wsl]
ansible.builtin.command:
cmd: mise install
become_user: "{{ username }}"
environment:
HOME: "{{ user_home }}"
when: >-
workstation_mise_java_where.rc != 0 or
workstation_mise_maven_where.rc != 0
- name: Ensure WSL boot configuration file exists
tags: [packages, services]
ansible.builtin.file:
path: /etc/wsl.conf
state: touch
owner: root
group: root
mode: "0644"
when: workstation_wsl_systemd_enabled | default(false)
- name: Enable systemd in WSL
tags: [packages, services]
community.general.ini_file:
path: /etc/wsl.conf
section: boot
option: systemd
value: 'true'
mode: "0644"
register: workstation_wsl_systemd_config
when: workstation_wsl_systemd_enabled | default(false)
- name: Note when WSL must be restarted
tags: [packages, services]
ansible.builtin.debug:
msg: "Restart the WSL distro with 'wsl --shutdown' from Windows to apply /etc/wsl.conf changes."
changed_when: false
when:
- workstation_wsl_systemd_enabled | default(false)
- workstation_wsl_systemd_config is changed