51 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.9 KiB
		
	
	
	
		
			YAML
		
	
	
	
	
	
---
 | 
						|
- name: "Install common dependencies"
 | 
						|
  ansible.builtin.apt:
 | 
						|
    name:
 | 
						|
      - software-properties-common
 | 
						|
      - ca-certificates
 | 
						|
      - apt-transport-https
 | 
						|
      - unzip
 | 
						|
    state: present
 | 
						|
    update_cache: yes
 | 
						|
 | 
						|
- name: "Add Ondřej PPA for PHP"
 | 
						|
  ansible.builtin.apt_repository:
 | 
						|
    repo: "ppa:ondrej/php"
 | 
						|
    state: present
 | 
						|
 | 
						|
# ------------------ WSL Configuration for Correct File Permissions ------------------
 | 
						|
# This block automatically detects and configures WSL for a seamless experience.
 | 
						|
 | 
						|
- name: "Check if running in a WSL environment"
 | 
						|
  ansible.builtin.stat:
 | 
						|
    path: /proc/version
 | 
						|
  register: proc_version_stat
 | 
						|
 | 
						|
- name: "Set is_wsl fact based on /proc/version content"
 | 
						|
  ansible.builtin.set_fact:
 | 
						|
    is_wsl: "{{ 'Microsoft' in (lookup('file', '/proc/version') | default('')) }}"
 | 
						|
  when: proc_version_stat.stat.exists
 | 
						|
 | 
						|
- name: "Ensure correct automount options are set in /etc/wsl.conf"
 | 
						|
  ansible.builtin.blockinfile:
 | 
						|
    path: /etc/wsl.conf
 | 
						|
    create: yes
 | 
						|
    owner: root
 | 
						|
    group: root
 | 
						|
    mode: '0644'
 | 
						|
    marker: "# {mark} ANSIBLE MANAGED BLOCK - LENVI AUTOMOUNT"
 | 
						|
    block: |
 | 
						|
      [automount]
 | 
						|
      enabled = true
 | 
						|
      options = "metadata,uid={{ ansible_user_uid }},gid={{ ansible_user_gid }},umask=22,fmask=11"
 | 
						|
      [user]
 | 
						|
      default = "{{ ansible_env.SUDO_USER | default(ansible_user_id) }}"
 | 
						|
  register: wsl_conf_result
 | 
						|
  when: is_wsl | default(false)
 | 
						|
 | 
						|
- name: "FOR WSL USER: This error is safe and intentional. Follow instructions below."
 | 
						|
  ansible.builtin.fail:
 | 
						|
    msg: |
 | 
						|
      ✅ ACTION REQUIRED: WSL Configuration was Updated! Lenverge has configured /etc/wsl.conf to fix file permissions. You MUST restart WSL for this change to take effect. Please perform the following steps: 1. Type 'logout' or 'exit' to exit WSL. 2. Run the command: wsl --shutdown 3. Wait a few seconds, then re-open your WSL terminal. 4. cd ~/Lenverge and Re-run ./lenverge.sh
 | 
						|
  when: wsl_conf_result.changed |