This repository intends to help setting my wsl environment within a Windows 10 machine.
The first step will be to install wsl on windows 10 so git is available. To do that run the following commands:
wsl --list --online #will return the list of available distrution names
wsl --install -d <<distribution_name>>
** In a corporate laptop make sure to run it as an admin from cmd
and not powershell. Powershell gives a priviledges error.
Every so ofter run wsl --update to make sure we are running latest
For example to upgrade the Ubuntu version from 20.04 to 22.04. Using the wsl commands described in the official microsoft docs:
wsl list #to display the current installed distributions
wsl --install -d Ubuntu22.04
wsl --distribution Ubuntu22.04 # to run it
A new Terminal Seems to be automatically installed when run Ubuntu for the first time. Here is the config that was created within the setting.json
:
{
"guid": "{e5a83caa-4c73-52b3-ae6b-bc438d721ef9}",
"hidden": false,
"name": "Ubuntu 22.04.3 LTS",
"source": "CanonicalGroupLimited.Ubuntu22.04LTS_79rhkp1fndgsc"
}
Because our playbook overrides the settings.json we will need to add this profile to the [settings.json](#files/windowsTerminal/settings.json)
After installing WSL we need to install Ansible on WSL. Ansible can run against different python versions.
Installing ansible from python. It will make ansible using the python version that was installed from
python3 -m pip ansible
Installing ansible with apt:
sudo apt update
sudo apt install software-properties-common
#No need to add repostory in ubuntu 20.04
#sudo apt-add-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
Installing ansible using apt, makes ansible use the python3 version that is configured. If python3
points to 3.8 will use 3.8, if it points to 3.10 it will use 3.10
- Create key account silently ssh-keygen -t ed25519 -C [email protected] -f ~/.ssh/id_ed25519_vecin2 -P ""
Open pub file a copy account and add it to your github profile notepad.exe ~/.ssh/id_ed25519_vecin2.pub
- Start ssh-agent and add key. Run setup_ssh_key.sh passing file name.
- Install chocolatey if not installed
- From an admin cmd install the following choco packages:
# Run ws_playbook
Ansible playbook to confire my dev work station.
Run it with `ansible-playbook local.yml -K` and enter the WSL sudo password.
Make sure this var is exported: export ANSIBLE_VAULT_PASSWORD_FILE=$HOME/vault_password.txt
- [Install ansible](./install_ansible.sh)
- Open playbook [linux_ws.yml](./linux_ws.yml) and review the tasks that will be installed
- Review [vars.yml](./vars.yml)
- Configure vault_password.txt file
- Run the playbook with either:
- [wsl-playbook](./run_linux_playbook.sh) - use this one for the first time
- `ansible-playbook linux_ws.yml -i inventor.yml
# For EM development
choco install -y tortoisesvn virtualbox vagrant
# Basic Packages
choco install -y notepadplusplus
Run the following command:
sudo sh -c "echo :WindowsBatch:E::bat::/init: > /proc/sys/fs/binfmt_misc/register"
Do not put on rc file as it prompts for password and it is no required to run everytime (maybe its required after each restart)
Having cargo module on ansible requires having later version allows using ansible-galaxy collect list To get the latest ansible version we need to add the ansible repository to apt: sudo apt -y install software-properties-common sudo apt-add-repository ppa:ansible/ansible
Add community collection, used to install cargo packages
-
choco install vcxsrv
-
WSL2 uses a different network setup the following line within you rc file export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
-
Run C:/Program Files/VcXsrv/xlaunch.exe:
- Multiple windows
- Start no client
- Clipboard/Native Opengl/Disable Access Control (all three ticked)
- Save config to starup folder so it runs on start
- Startup folderi
- Windows key + r: shell: Startup
- C:\Users\dgarcia\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup
Also because it a external address the xlaunch configuration needs to have checked Disable Access Control so it accepts conexions
Copy ./files/Caskadia Cove Nerd Font Complete Windows Compatible.tff into your desktop. Open it and install it.
Copying nerdfonts into c:\windows\Fonts
might give permission issues.
Change nerdfonts path to something that does ont give pemisission error and then copy manually from windows
Current windows terminal files/settings.json
is pointing to the font so web-devicons are working on the terminal.
Fira Code: https://github.com/ryanoasis/nerd-fonts/releases/download/v3.1.1/FiraCode.zip
#Install on ubuntu ag silver searcher so FZF Ctrl+t works
Windows 10 box runs really slow. Thats related to Hyper-v still running an VirtualBox ends up using it. To turn off Hyper-v run the following command as an admin from the cmd: bcdedit /set hypervisorlaunchtype off
The issue then is that WSL2 wont start MicrosoftDocs/WSL#798
Some vagrant boxes, like oracle 19.3, configure VirtualBox to use a NAT network only. Then they use port forwarding on 1521 from localhost into the VirtualBox machine. However, this approach doesn't work when accessing from WSL. We have to use static ip address.
This article describes how to implement, at least for fedora linux system, which is the one used by the oracle19.3 vagant box. Main section from that article:
Create a file called ifcfg-enp0s8 in /etc/sysconfig/network-scripts/
and give it the following contents:
DEVICE=enp0s8 BOOTPROTO=static ONBOOT=yes IPADDR=192.168.99.10 NETMASK=255.255.255.0 Where NETMASK should match the settings for your host-only network as obtained above and IPADDR should be an available IP address in the host-only network (again, typically in 2-254 range).
Now run systemctl restart network
Disable plugins: mi Search word on cwi: g Search word under cursor on cwi: ag Open File: t Open Buffer: b
Download vcxsrv Run installer using default options Run vcxsrv using "xlaunch" (search in the start menu) Add export DISPLAY=localhost:0.0 to your wsl bashrc
WSL2 uses a different network so instead we should use: export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
Also because it a external address the xlaunch configuration needs to have checked Disable Access Control so it accepts conexions
##packages x - install vim configure vim as in linux choco install wsltty vlc -video
#Windows Remove bell on the command line/WSL Install spanish language copy text from tmux ctrl [ and then paste in vim paste in vim with "+ not working
choco install virtualbox choco install vagrant
##in wsl run sudo apt-get install subversion
WSL shares the network with the Windows Host while WSL2 has its own network. when running playbooks against the windows host this translates in WSL being able to use "localhost" while WSL2 will have to specify the Windows Host ip address within the Hyper-V WSL network.
In a "worklaptop_WSL" I want to set the var ansible_python_interpreter put it into inventory
Vim Syntastic and Nerdtree git failed when saving python files if the file was not open with nerdtree In case this issue has not been fixed, there is a workaround:
Add to nerdtree-git-plugin/nerdtree_plugin/git_status.vim: augroup nerdtreegitplugin autocmd BufWritePost * call s:FileUpdate(expand("%:p")) augroup END
Before: " FUNCTION: s:FileUpdate(fname) {{{2 function! s:FileUpdate(fname)
Running in wsl/ubuntu need libaio1 package and oracle instant client Then set env var: export LD_LIBRARY_PATH=/usr/lib/oracle//client(64)/lib/${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}
Running ipconfig on windows will give a wsl ethernet adapter get ip from there e.g 172.24.128.1
Install tmux plugin by running Ctrl+a+I