Skip to content

sjlex/ansible-wsl

Repository files navigation


Ansible Playbooks for WSL Logo
Ansible Playbooks for WSL

Ansible playbooks for provisioning WSL-1 and WSL-2.

Version  GitHub License 

Screenshot

Table of contents

Getting started

Prerequisites

Supported Operating Systems:

Platform Versions
Debian Bookworm - 12, Trixie - 13

Installation

Install WSL

  • WSL-1:

    wsl --set-default-version 1
    wsl --import debian-wsl1 C:\wsl\debian-wsl1 install.tar.gz
  • WSL-2:

    wsl --set-default-version 2
    wsl --import debian-wsl2 C:\wsl\debian-wsl2 install.tar.gz

Post-Install

wsl --set-default-version 2
wsl --set-default debian-wsl2

Bootstrap

  • Launch WSL distribution and login (root):

    wsl -d debian-wsl1 -u root
    wsl -d debian-wsl2 -u root
  • Install the required dependencies:

    apt install -y python3 python3-poetry python-is-python3 pyenv git
    pyenv install
    ./bin/task dependencies:install

Run Playbooks

  • WSL-1:

    ./bin/task run:local:wsl1
  • WSL-2:

    ./bin/task run:local:wsl2

Finalization

Set user password

passwd <username>

Clear

  • Cache and Python environment cleanup:
./bin/task clear

Development

Dev-Container

Build the Docker image:

./bin/task docker:build

Run the Docker container:

./bin/task docker:dev:run

Install dependencies:

task dependencies:dev:install

Testing

Roles

Run tests for all roles:
task test:role:all
Run tests for a specific role:
task test:role -- fish

or:

cd roles/fish
molecule test --all
Run tests manually:
cd roles/fish
molecule create &&
molecule converge &&
molecule verify &&
molecule idempotence &&
molecule destroy
Login
molecule list
molecule login --host wsl_role-fish_debian13_

Playbooks

Run integration tests:
task test:integration:all
Run integration tests for a specific scenario:
  • Run Molecule Default scenario (docker):

    task test:integration:default
  • Run Molecule VM scenario (vagrant + libvirt + qemu):

    task test:integration:main-vm
Run integration tests manually:
  • Run Molecule Default scenario (docker):

    molecule create -s default &&
    molecule converge -s default &&
    molecule verify -s default &&
    molecule idempotence -s default &&
    molecule destroy -s default
  • Run Molecule VM scenario (vagrant + libvirt + qemu):

    molecule create -s main-vm &&
    molecule converge -s main-vm &&
    molecule verify -s main-vm &&
    molecule idempotence -s main-vm &&
    molecule destroy -s main-vm
Login
molecule list
molecule login -s default --host playbook-main-debian13-

or:

molecule login -s main-vm --host playbook-main-debian13-
  • Switch to user:
sudo su - <user>

Linting

task lint
task lint:fix

Clear All

  • Cache and Python environment cleanup:
task clear

License

MIT License

Third-Party Assets

This project may include or reference third-party assets under their own licenses. Any such assets are used in accordance with their licensing terms.

About

Ansible playbooks for provisioning WSL-1 and WSL-2.

Topics

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Packages

 
 
 

Contributors