Skip to content

Commit d4c6ba7

Browse files
authored
Merge pull request #70 from dotkernel/issue-69
Issue #69: Unable to start `Apache`/`MariaDB` on startup
2 parents fef7e6b + bf1507c commit d4c6ba7

File tree

10 files changed

+160
-6
lines changed

10 files changed

+160
-6
lines changed

docs/book/v1/setup/installation.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
11
# Install AlmaLinux9
22

3+
Before proceeding with the installation, we need to make sure that no other WSL2 distribution (aka: _distro_) is running.
4+
This is important because this installation will fail if required ports are already in use by another distro.
5+
36
Open `Windows Terminal`.
47

5-
List the available Linux distributions (aka: _distros_) by executing:
8+
## Stop other WSL2 distros
9+
10+
List all installed distros:
11+
12+
```shell
13+
wsl -l -v
14+
```
15+
16+
If there is no other distro installed, you will see the below output (an empty list):
17+
18+
```text
19+
NAME STATE VERSION
20+
```
21+
22+
In this case, you can jump to the [installation](#install-almalinux9-1) section.
23+
24+
If you have other distros installed, the output could look similar to the below:
25+
26+
```text
27+
NAME STATE VERSION
28+
* AlmaLinux-9 Stopped 2
29+
* AlmaLinux-10 Running 2
30+
```
31+
32+
Make sure that the **STATE** column reads **Stopped** for all distros.
33+
If any of them reads **Running**, you must stop if first by executing `wsl -t <distro-name>`, for example: `wsl -t AlmaLinux-10`.
34+
Once you have stopped all distros, you can continue to the [installation](#install-almalinux9-1) section.
35+
36+
## Install AlmaLinux9
37+
38+
List the available Linux distros by executing:
639

740
```shell
841
wsl --list --online

docs/book/v2/setup/installation.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
11
# Install AlmaLinux10
22

3+
Before proceeding with the installation, we need to make sure that no other WSL2 distribution (aka: _distro_) is running.
4+
This is important because this installation will fail if required ports are already in use by another distro.
5+
36
Open `Windows Terminal`.
47

5-
List the available Linux distributions (aka: _distros_) by executing:
8+
## Stop other WSL2 distros
9+
10+
List all installed distros:
11+
12+
```shell
13+
wsl -l -v
14+
```
15+
16+
If there is no other distro installed, you will see the below output (an empty list):
17+
18+
```text
19+
NAME STATE VERSION
20+
```
21+
22+
In this case, you can jump to the [installation](#install-almalinux10-1) section.
23+
24+
If you have other distros installed, the output could look similar to the below:
25+
26+
```text
27+
NAME STATE VERSION
28+
* AlmaLinux-8 Stopped 2
29+
* AlmaLinux-9 Running 2
30+
```
31+
32+
Make sure that the **STATE** column reads **Stopped** for all distros.
33+
If any of them reads **Running**, you must stop if first by executing `wsl -t <distro-name>`, for example: `wsl -t AlmaLinux-9`.
34+
Once you have stopped all distros, you can continue to the [installation](#install-almalinux10-1) section.
35+
36+
## Install AlmaLinux10
37+
38+
List the available Linux distros by executing:
639

740
```shell
841
wsl --list --online

docs/book/v2/setup/setup-packages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Update/Upgrade system packages:
2929
sudo dnf upgrade -y
3030
```
3131

32-
Now, install the latest version of **Ansible Core** and run **ansible-galaxy** in order to install collections:
32+
Now, install the latest version of **Ansible Core** and run **ansible-galaxy** to install collections:
3333

3434
```shell
3535
sudo dnf install ansible-core -y

wsl/README.md

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,41 @@
11
# Install AlmaLinux10
22

3+
Before proceeding with the installation, we need to make sure that no other WSL2 distribution (aka: _distro_) is running.
4+
This is important because this installation will fail if required ports are already in use by another distro.
5+
36
Open `Windows Terminal`.
47

5-
List the available Linux distributions (aka: _distros_) by executing:
8+
## Stop other WSL2 distros
9+
10+
List all installed distros:
11+
12+
```shell
13+
wsl -l -v
14+
```
15+
16+
If there is no other distro installed, you will see the below output (an empty list):
17+
18+
```text
19+
NAME STATE VERSION
20+
```
21+
22+
In this case, you can jump to the [installation](#install-almalinux10-1) section.
23+
24+
If you have other distros installed, the output could look similar to the below:
25+
26+
```text
27+
NAME STATE VERSION
28+
* AlmaLinux-8 Stopped 2
29+
* AlmaLinux-9 Running 2
30+
```
31+
32+
Make sure that the **STATE** column reads **Stopped** for all distros.
33+
If any of them reads **Running**, you must stop if first by executing `wsl -t <distro-name>`, for example: `wsl -t AlmaLinux-9`.
34+
Once you have stopped all distros, you can continue to the [installation](#install-almalinux10-1) section.
35+
36+
## Install AlmaLinux10
37+
38+
List the available Linux distros by executing:
639

740
```shell
841
wsl --list --online
@@ -39,6 +72,14 @@ OracleLinux_9_1 Oracle Linux 9.1
3972

4073
Note the two columns: **NAME** and **FRIENDLY NAME**.
4174
To install a specific distro, use the value from the **NAME** column, in this case: `AlmaLinux-10`.
75+
76+
> If you try to install a distro that is already installed, the installation process will fail:
77+
>
78+
> Downloading: AlmaLinux OS 10
79+
> Installing: AlmaLinux OS 10
80+
> A distribution with the supplied name already exists. Use --name to choose a different name.
81+
> Error code: Wsl/InstallDistro/Service/RegisterDistro/ERROR_ALREADY_EXISTS
82+
4283
Install the AlmaLinux10 distro by executing the below command:
4384

4485
```shell
@@ -112,7 +153,7 @@ Update/Upgrade system packages:
112153
sudo dnf upgrade -y
113154
```
114155

115-
Now, install the latest version of **Ansible Core** and run **ansible-galaxy** in order to install collections:
156+
Now, install the latest version of **Ansible Core** and run **ansible-galaxy** to install collections:
116157

117158
```shell
118159
sudo dnf install ansible-core -y

wsl/install.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@
77
vars_files:
88
- ./config.yml
99
- ./roles/apache/vars/main.yml
10+
- ./roles/system/vars/main.yml
1011
tasks:
1112
- name: Install and configure packages
1213
include_role:
1314
name: "{{ role }}"
1415
tasks_from: main
1516
loop:
16-
- system
1717
- apache
1818
- php
1919
- mariadb
2020
- phpmyadmin
21+
- system
2122
- composer
2223
- nodejs
2324
- git

wsl/roles/git/tasks/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
value: "{{ item.value }}"
1010
scope: global
1111
with_dict: "{{ git_config }}"
12+
become: false
1213
- name: Apply global user configurations
1314
git_config:
1415
name: "{{ item.key }}"
1516
value: "{{ item.value }}"
1617
scope: global
1718
with_dict: "{{ config.git.config }}"
19+
become: false

wsl/roles/system/tasks/main.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,24 @@
2222
template:
2323
src: bash_profile.j2
2424
dest: "{{ bash_profile_dest }}"
25+
- name: Add create runtime directories script
26+
template:
27+
src: runtime-directories.sh.j2
28+
dest: "{{ runtime_directories_script_path }}"
29+
mode: "0755"
30+
- name: Add create runtime directories service
31+
template:
32+
src: runtime-directories.service.j2
33+
dest: "{{ runtime_directories_service_path }}"
34+
mode: "0755"
35+
- name: Reload systemd
36+
ansible.builtin.systemd:
37+
daemon_reload: yes
38+
- name: Enable runtime-directories.service
39+
ansible.builtin.systemd:
40+
name: runtime-directories.service
41+
enabled: yes
42+
- name: Start runtime-directories.service
43+
ansible.builtin.systemd:
44+
name: runtime-directories.service
45+
state: started
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[Unit]
2+
Description=Create runtime directories for Apache and MariaDB
3+
DefaultDependencies=no
4+
After=local-fs.target
5+
Before=httpd.service mariadb.service
6+
7+
[Service]
8+
Type=oneshot
9+
ExecStart={{ runtime_directories_script_path }}
10+
RemainAfterExit=true
11+
12+
[Install]
13+
WantedBy=multi-user.target
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Create /run/httpd with correct ownership and permissions
5+
install -d -o apache -g apache -m 0755 /run/httpd
6+
7+
# Create /run/mariadb with correct ownership and permissions
8+
install -d -o mysql -g mysql -m 0755 /run/mariadb

wsl/roles/system/vars/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
---
22
wsl_config_dest: /etc/wsl.conf
33
bash_profile_dest: "/home/{{ config.system.username }}/.bash_profile"
4+
runtime_directories_script_path: "/usr/local/bin/runtime-directories.sh"
5+
runtime_directories_service_path: "/etc/systemd/system/runtime-directories.service"

0 commit comments

Comments
 (0)