An open API service indexing awesome lists of open source software.

https://github.com/jacquindev/automated-devops-wsl2

[WIP] Automated setting up DevOps environments in WSL2 machine. Installation of tools (Vagrant, Terraform, Ansible, Packer, AWS-CLI, Jenkins, asdf, etc.) and configurations.
https://github.com/jacquindev/automated-devops-wsl2

ansible ansible-playbook devops ubuntu wsl2

Last synced: 3 months ago
JSON representation

[WIP] Automated setting up DevOps environments in WSL2 machine. Installation of tools (Vagrant, Terraform, Ansible, Packer, AWS-CLI, Jenkins, asdf, etc.) and configurations.

Awesome Lists containing this project

README

        

Automated WSL2 Ubuntu Setup

Automatically WSL2 Ubuntu DevOps Development Environments On WSL2 Ubuntu

> [!WARNING]
> This is a **Work In Progress** project. **!! PLEASE USE WITH CAUTION !!**


This repository contains Ansible playbooks to automatically configure WSL2 Ubuntu machine.

You may also need to have **[Docker Desktop](https://www.docker.com/products/docker-desktop/)** installed for full development experiments.

## ✨ Features

This repository is bundled with automated installations of:

- ***[Hashicorp](https://www.hashicorp.com/en)***'s tools:
- [Vagrant](https://www.vagrantup.com/): configure to use with Windows VirtualBox ***(required VirtualBox installed on Windows)*** + plugins
- [Terraform](https://www.terraform.io/)
- [Packer](https://www.packer.io/)
- [Vault](https://www.hashicorp.com/en/products/vault)
- etc
- ***[AWS](https://docs.aws.amazon.com/)***:
- Configure aws authentication *( Please setup your `aws_access_key` and `aws_secret_key`)*
- ***[asdf](https://asdf-vm.com/)***:
- Install multiple tools via ***asdf*** (Please note that `asdf` would be installed using `Homebrew`)
- Automatically setup your `.bashrc` file with extra configurations:
- E.g: source ***`set-env.bash`*** file of `golang` plugin
- Add non-default settings of default packages file
- ***[Jenkins](https://www.jenkins.io/)***:
- Install, enable, and start Jenkins service, default url: **http://localhost:8080/**, you can change this in *[configuration file](./ansible/base/config.yml)*
- Bundled with tons of Jenkins plugins
- ***[git](https://git-scm.com/)***:
- Configure git to use with Windows machine (`credential.helper`)
- Install GitHub CLI plugins (if configured)

## 🌷Usage

> [!NOTE]
> You will NEED to create a `config.yml` in [ansible](./ansible) folder in order to have correct setup.

> It is not best to expose your SECRET TOKENS, try to use ansible-vault for avoiding security risks.

>

> Default configurations are in [default.config.yml](./ansible/default.config.yml) file.

> ANY MODIFICATIONS CAN BE DONE IN YOUR OWN `config.yml`.

### Step 1: Clone this repository on a fresh, clean WSL2 Ubuntu machine:

```bash
git clone https://github.com/jacquindev/automated-devops-wsl2.git /your/location
```

### Step 2: `cd` into `/your/location` and add your own `config.yml` file in [ansible](./ansible) directory. (This will also install `ansible` if not found)

Ansible variables that **MUST** be considered:

```yaml
git_username: "" # e.g: John Doe
git_email: "" # e.g: [email protected]
```

If you want to install `ngrok`, ensure that **`configure_ngrok`** is set to **`true`**, and add your auth ngrok token, which can be retrieved from this link -> **[Your NGROK Token](https://dashboard.ngrok.com/get-started/your-authtoken)**:

```yaml
configure_ngrok: true
ngrok_token: ""
```

For AWS configuration, ensure that **`configure_aws`** is set to **`true`**, and we would set up AWS entry points to connect to your AWS ACCOUNT:

```yaml
configure_aws: true

aws_access_key: ""
aws_secret_key: ""
```

If you want to setup your own **dotfiles**, make sure that **`configure_dotfiles`** is set to **`true`**, and add your own repository url in **`dotfiles_repo`** and **`dotfiles_repo_version`**.

```yaml
configure_dotfiles: true

dotfiles_repo: "" # e.g: https://github.com/jacquindev/dotfiles.git
dotfiles_repo_version: master # e.g: main
```

For more information, please see ***[geerlingguy.dotfiles](https://github.com/geerlingguy/ansible-role-dotfiles)***

Make WSL2 Ubuntu instance to automatically install and setup Jenkins, we use `geerlingguy.jenkins` and `geerlingguy.java` role for convenience sake:

```yaml
java_packages:
- openjdk-17-jre

# Add more plugins here
jenkins_plugins:
- ansicolor
- docker-workflow
```

For more information, please visit [geerlingguy.jenkins](https://github.com/geerlingguy/ansible-role-jenkins) and [geerlingguy.java](https://github.com/geerlingguy/ansible-role-java) for complete lists of settings available.

This repo will setup **SonarQube** using **Docker Compose**. On your Windows machine, ensure that *Docker Desktop* is installed and running. Then in your config file, set:

```yaml
configure_sonarqube: true

# Add where would you place docker-compose.yml file in, for example:
sonarqube_config_path: "{{ ansible_user_dir }}/projects/sonarqube"
```

### Step 3: Run [init.sh](./init.sh) script

This script will upgrade your system, install `ansible` if not found, and run the playbooks.

```bash
. ./init.sh
```

## Full example of `config.yml` file

```yaml
---

configure_asdf: true
configure_aws: true
configure_dotfiles: true
configure_git: true
configure_hashicorp: true
configure_jenkins: true
configure_ngrok: true
configure_sonarqube: true

# ----------------------------------------------------------------
apt_packages:
- apt-transport-https
- binutils
- build-essential
- coreutils
- curl
- file
- fontconfig
- git
- gnupg2
- unzip
- wget
- zip
- zsh

homebrew_taps: []

homebrew_packages:
- asdf
- eza
- fd
- fzf
- jq
- luarocks
- minikube
- neovim
- ripgrep
- starship
- wrk
- yazi
- yq

git_username: ""
git_email: ""

git_addons: # The below addons are installed by Homebrew
- gh
- git-delta
- git-extras

git_delta_configure: true

gh_extensions: # required you have logged into your GitHub account using `gh auth login` first
- dlvhdr/gh-dash
- gennaro-tedesco/gh-f
- gennaro-tedesco/gh-s

asdf_legacy_version_file: yes
asdf_plugin_repository_last_check_duration: 0

asdf_dependencies: []

asdf_plugins:
- name: python
repo: https://github.com/asdf-community/asdf-python.git
versions:
- 3.13.2
global: 3.13.2

- name: nodejs
repo: https://github.com/asdf-vm/asdf-nodejs.git
versions:
- 23.9.0
- 22.14.0
global: 23.9.0

- name: java
repo: https://github.com/halcyon/asdf-java.git
versions:
- corretto-17.0.14.7.1
global: corretto-17.0.14.7.1

asdf_external_sources:
- name: golang
file: set-env.bash
- name: java
file: set-java-home.bash

asdf_environments:
- option: "ASDF_NODEJS_LEGACY_FILE_DYNAMIC_STRATEGY"
value: "latest_available"
- option: "ASDF_NPM_DEFAULT_PACKAGES_FILE"
value: "{{ asdf_config_dir }}/.default-npm-packages"
- option: "ASDF_PYTHON_DEFAULT_PACKAGES_FILE"
value: "{{ asdf_config_dir }}/.default-python-packages"

dotfiles_repo: https://github.com/jacquindev/dotfiles.git
dotfiles_repo_version: master
dotfiles_repo_accept_hostkey: true

dotfiles_home: "~"
dotfiles_repo_local_destination: "~/.dotfiles"

dotfiles_files:
- .zshenv
- .config

ngrok_authtoken: ""
ngrok_api_key: ""
ngrok_connect_url: ""
ngrok_server_addr: ""

hashicorp_from_apt: false
hashicorp_from_homebrew: true

hashicorp_apt_packages: []

hashicorp_homebrew_packages:
- hashicorp/tap/packer
- hashicorp/tap/terraform
- hashicorp/tap/vagrant
- hashicorp/tap/vault

vagrant_windows_home: /mnt/c/Users/username

vagrant_plugins:
- virtualbox_WSL2 # required for `vagrant ssh` to work in WSL2
- vagrant-hostmanager
- vagrant-reload
- vagrant-share
- vagrant-timezone

aws_from_homebrew: true

aws_access_key: ""
aws_secret_key: ""

sonarqube_config_path: "{{ ansible_user_dir }}/projects/sonarqube"

java_packages:
- openjdk-17-jre

jenkins_restart_behavior: safe-restart

jenkins_plugins:
- ansicolor
- blueocean
- docker-workflow
```

## 🎉 Credits

This project was heavily inspired by *[geerlingguy/mac-dev-playbook](https://github.com/geerlingguy/mac-dev-playbook)*

References / Sources:
- [cimon-io/ansible-role-asdf](https://github.com/cimon-io/ansible-role-asdf)
- [fazlearefin/ubuntu-dev-machine-setup](https://github.com/fazlearefin/ubuntu-dev-machine-setup)

## 📜 License

Licensed under the [MIT License](https://github.com/jacquindev/automated-devops-wsl2/blob/master/LICENSE).

## 👤 Author

This project was created in 2025 by [Jacquin Moon](https://github.com/jacquindev)