wsl permission
This commit is contained in:
		
							parent
							
								
									bcc77ad88e
								
							
						
					
					
						commit
						2e6e278fc4
					
				@ -31,7 +31,7 @@ This is the most important step. Open the `Lenvi.yaml` file and define your enti
 | 
				
			|||||||
    **Example** `Lenvi.yaml`**:**
 | 
					    **Example** `Lenvi.yaml`**:**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
```yaml
 | 
					```yaml
 | 
				
			||||||
db_engine: "mariadb" #mariadb, mysql post
 | 
					db_engine: "mariadb" #mariadb, mysql or postgresql
 | 
				
			||||||
db_credentials:
 | 
					db_credentials:
 | 
				
			||||||
  user: "Lenvi"
 | 
					  user: "Lenvi"
 | 
				
			||||||
  password: "secret"
 | 
					  password: "secret"
 | 
				
			||||||
 | 
				
			|||||||
@ -5,10 +5,62 @@
 | 
				
			|||||||
      - software-properties-common
 | 
					      - software-properties-common
 | 
				
			||||||
      - ca-certificates
 | 
					      - ca-certificates
 | 
				
			||||||
      - apt-transport-https
 | 
					      - apt-transport-https
 | 
				
			||||||
 | 
					      - unzip
 | 
				
			||||||
    state: present
 | 
					    state: present
 | 
				
			||||||
    update_cache: yes
 | 
					    update_cache: yes
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: "Add Ondřej PPA for PHP"
 | 
					- name: "Add Ondřej PPA for PHP"
 | 
				
			||||||
  ansible.builtin.apt_repository:
 | 
					  ansible.builtin.apt_repository:
 | 
				
			||||||
    repo: "ppa:ondrej/php"
 | 
					    repo: "ppa:ondrej/php"
 | 
				
			||||||
    state: present
 | 
					    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_user_id }}
 | 
				
			||||||
 | 
					  register: wsl_conf_result
 | 
				
			||||||
 | 
					  when: is_wsl | default(false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: "STOP PLAYBOOK: Force user to restart WSL if wsl.conf was changed"
 | 
				
			||||||
 | 
					  ansible.builtin.fail:
 | 
				
			||||||
 | 
					    msg: |
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      🛑 ACTION REQUIRED: WSL Configuration Was Updated!
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      The playbook has configured /etc/wsl.conf to fix file permissions.
 | 
				
			||||||
 | 
					      You MUST restart WSL for this change to take effect. The playbook has been stopped.
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      Please perform the following steps:
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      1. Close this terminal.
 | 
				
			||||||
 | 
					      2. Open Windows PowerShell or CMD (not as admin).
 | 
				
			||||||
 | 
					      3. Run the command:   wsl --shutdown
 | 
				
			||||||
 | 
					      4. Wait a few seconds, then re-open your WSL terminal.
 | 
				
			||||||
 | 
					      5. Re-run the Lenvi playbook:   ansible-playbook playbook.yml -i inventory --ask-become-pass
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					      After restarting, your file permission issues will be permanently solved.
 | 
				
			||||||
 | 
					      
 | 
				
			||||||
 | 
					  when: wsl_conf_result.changed
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user