-
Notifications
You must be signed in to change notification settings - Fork 0
/
iiac-wsl2-env.yaml
50 lines (43 loc) · 1.55 KB
/
iiac-wsl2-env.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
---
# IIaC WSL2 Environment Playbook
-
# Hosts: where our play will run and options it will run with
hosts: localhost
connection: local
# Vars: variables that will apply to the play, on all targets
# Tasks: the list of tasks that will be executed within
# the play, this section can also be used for
# pre and post tasks
tasks:
- name: Set wsl2_environment fact default to false
set_fact:
wsl2_environment: false
- name: Set wsl2_environment fact True
set_fact:
wsl2_environment: true
when: ansible_kernel is search("microsoft-standard-WSL2")
- name: Set iiac_username
set_fact:
iiac_username: "{{ ansible_user_id }}"
- name: Display wsl2_environment and iiac_username
debug:
msg: "WSL2 = {{ wsl2_environment }} | iiac_username = {{ iiac_username }}"
- name: Add WSL2 required variables to the environment
lineinfile:
path: "/home/{{ iiac_username }}/.bashrc"
line: "{{ item }}"
create: true
mode: 0644
owner: "{{ iiac_username }}"
with_items:
- export DONT_PROMPT_WSL_INSTALL=1
- export VAGRANT_WSL_ENABLE_WINDOWS_ACCESS=1
- export PATH="$PATH:/mnt/c/Program Files/Oracle/VirtualBox"
when: wsl2_environment
- name: Inform user to source .bashrc
debug:
msg: "Please run: source /home/{{ iiac_username }}/.bashrc"
# Handlers: the list of handlers that are executed as a notify
# key from a task
# Roles: list of roles to be imported into the play
...