diff --git a/docs/book/v1/setup/installation.md b/docs/book/v1/setup/installation.md index ca543a3..1242cc8 100644 --- a/docs/book/v1/setup/installation.md +++ b/docs/book/v1/setup/installation.md @@ -1,8 +1,41 @@ # Install AlmaLinux9 +Before proceeding with the installation, we need to make sure that no other WSL2 distribution (aka: _distro_) is running. +This is important because this installation will fail if required ports are already in use by another distro. + Open `Windows Terminal`. -List the available Linux distributions (aka: _distros_) by executing: +## Stop other WSL2 distros + +List all installed distros: + +```shell +wsl -l -v +``` + +If there is no other distro installed, you will see the below output (an empty list): + +```text + NAME STATE VERSION +``` + +In this case, you can jump to the [installation](#install-almalinux9-1) section. + +If you have other distros installed, the output could look similar to the below: + +```text + NAME STATE VERSION +* AlmaLinux-9 Stopped 2 +* AlmaLinux-10 Running 2 +``` + +Make sure that the **STATE** column reads **Stopped** for all distros. +If any of them reads **Running**, you must stop if first by executing `wsl -t `, for example: `wsl -t AlmaLinux-10`. +Once you have stopped all distros, you can continue to the [installation](#install-almalinux9-1) section. + +## Install AlmaLinux9 + +List the available Linux distros by executing: ```shell wsl --list --online diff --git a/docs/book/v2/setup/installation.md b/docs/book/v2/setup/installation.md index f47b321..c36a0c8 100644 --- a/docs/book/v2/setup/installation.md +++ b/docs/book/v2/setup/installation.md @@ -1,8 +1,41 @@ # Install AlmaLinux10 +Before proceeding with the installation, we need to make sure that no other WSL2 distribution (aka: _distro_) is running. +This is important because this installation will fail if required ports are already in use by another distro. + Open `Windows Terminal`. -List the available Linux distributions (aka: _distros_) by executing: +## Stop other WSL2 distros + +List all installed distros: + +```shell +wsl -l -v +``` + +If there is no other distro installed, you will see the below output (an empty list): + +```text + NAME STATE VERSION +``` + +In this case, you can jump to the [installation](#install-almalinux10-1) section. + +If you have other distros installed, the output could look similar to the below: + +```text + NAME STATE VERSION +* AlmaLinux-8 Stopped 2 +* AlmaLinux-9 Running 2 +``` + +Make sure that the **STATE** column reads **Stopped** for all distros. +If any of them reads **Running**, you must stop if first by executing `wsl -t `, for example: `wsl -t AlmaLinux-9`. +Once you have stopped all distros, you can continue to the [installation](#install-almalinux10-1) section. + +## Install AlmaLinux10 + +List the available Linux distros by executing: ```shell wsl --list --online diff --git a/docs/book/v2/setup/setup-packages.md b/docs/book/v2/setup/setup-packages.md index 5c38895..e250afa 100644 --- a/docs/book/v2/setup/setup-packages.md +++ b/docs/book/v2/setup/setup-packages.md @@ -29,7 +29,7 @@ Update/Upgrade system packages: sudo dnf upgrade -y ``` -Now, install the latest version of **Ansible Core** and run **ansible-galaxy** in order to install collections: +Now, install the latest version of **Ansible Core** and run **ansible-galaxy** to install collections: ```shell sudo dnf install ansible-core -y diff --git a/wsl/README.md b/wsl/README.md index 3219ffb..ea82e86 100644 --- a/wsl/README.md +++ b/wsl/README.md @@ -1,8 +1,41 @@ # Install AlmaLinux10 +Before proceeding with the installation, we need to make sure that no other WSL2 distribution (aka: _distro_) is running. +This is important because this installation will fail if required ports are already in use by another distro. + Open `Windows Terminal`. -List the available Linux distributions (aka: _distros_) by executing: +## Stop other WSL2 distros + +List all installed distros: + +```shell +wsl -l -v +``` + +If there is no other distro installed, you will see the below output (an empty list): + +```text + NAME STATE VERSION +``` + +In this case, you can jump to the [installation](#install-almalinux10-1) section. + +If you have other distros installed, the output could look similar to the below: + +```text + NAME STATE VERSION +* AlmaLinux-8 Stopped 2 +* AlmaLinux-9 Running 2 +``` + +Make sure that the **STATE** column reads **Stopped** for all distros. +If any of them reads **Running**, you must stop if first by executing `wsl -t `, for example: `wsl -t AlmaLinux-9`. +Once you have stopped all distros, you can continue to the [installation](#install-almalinux10-1) section. + +## Install AlmaLinux10 + +List the available Linux distros by executing: ```shell wsl --list --online @@ -39,6 +72,14 @@ OracleLinux_9_1 Oracle Linux 9.1 Note the two columns: **NAME** and **FRIENDLY NAME**. To install a specific distro, use the value from the **NAME** column, in this case: `AlmaLinux-10`. + +> If you try to install a distro that is already installed, the installation process will fail: +> +> Downloading: AlmaLinux OS 10 +> Installing: AlmaLinux OS 10 +> A distribution with the supplied name already exists. Use --name to choose a different name. +> Error code: Wsl/InstallDistro/Service/RegisterDistro/ERROR_ALREADY_EXISTS + Install the AlmaLinux10 distro by executing the below command: ```shell @@ -112,7 +153,7 @@ Update/Upgrade system packages: sudo dnf upgrade -y ``` -Now, install the latest version of **Ansible Core** and run **ansible-galaxy** in order to install collections: +Now, install the latest version of **Ansible Core** and run **ansible-galaxy** to install collections: ```shell sudo dnf install ansible-core -y diff --git a/wsl/install.yml b/wsl/install.yml index 0509ddf..7a7a44f 100644 --- a/wsl/install.yml +++ b/wsl/install.yml @@ -7,17 +7,18 @@ vars_files: - ./config.yml - ./roles/apache/vars/main.yml + - ./roles/system/vars/main.yml tasks: - name: Install and configure packages include_role: name: "{{ role }}" tasks_from: main loop: - - system - apache - php - mariadb - phpmyadmin + - system - composer - nodejs - git diff --git a/wsl/roles/git/tasks/main.yml b/wsl/roles/git/tasks/main.yml index 844037d..f0752ec 100644 --- a/wsl/roles/git/tasks/main.yml +++ b/wsl/roles/git/tasks/main.yml @@ -9,9 +9,11 @@ value: "{{ item.value }}" scope: global with_dict: "{{ git_config }}" + become: false - name: Apply global user configurations git_config: name: "{{ item.key }}" value: "{{ item.value }}" scope: global with_dict: "{{ config.git.config }}" + become: false diff --git a/wsl/roles/system/tasks/main.yml b/wsl/roles/system/tasks/main.yml index fe0e7f1..b96f5c4 100644 --- a/wsl/roles/system/tasks/main.yml +++ b/wsl/roles/system/tasks/main.yml @@ -22,3 +22,24 @@ template: src: bash_profile.j2 dest: "{{ bash_profile_dest }}" +- name: Add create runtime directories script + template: + src: runtime-directories.sh.j2 + dest: "{{ runtime_directories_script_path }}" + mode: "0755" +- name: Add create runtime directories service + template: + src: runtime-directories.service.j2 + dest: "{{ runtime_directories_service_path }}" + mode: "0755" +- name: Reload systemd + ansible.builtin.systemd: + daemon_reload: yes +- name: Enable runtime-directories.service + ansible.builtin.systemd: + name: runtime-directories.service + enabled: yes +- name: Start runtime-directories.service + ansible.builtin.systemd: + name: runtime-directories.service + state: started diff --git a/wsl/roles/system/templates/runtime-directories.service.j2 b/wsl/roles/system/templates/runtime-directories.service.j2 new file mode 100644 index 0000000..ae28193 --- /dev/null +++ b/wsl/roles/system/templates/runtime-directories.service.j2 @@ -0,0 +1,13 @@ +[Unit] +Description=Create runtime directories for Apache and MariaDB +DefaultDependencies=no +After=local-fs.target +Before=httpd.service mariadb.service + +[Service] +Type=oneshot +ExecStart={{ runtime_directories_script_path }} +RemainAfterExit=true + +[Install] +WantedBy=multi-user.target diff --git a/wsl/roles/system/templates/runtime-directories.sh.j2 b/wsl/roles/system/templates/runtime-directories.sh.j2 new file mode 100644 index 0000000..a3fcf7d --- /dev/null +++ b/wsl/roles/system/templates/runtime-directories.sh.j2 @@ -0,0 +1,8 @@ +#!/bin/bash +set -e + +# Create /run/httpd with correct ownership and permissions +install -d -o apache -g apache -m 0755 /run/httpd + +# Create /run/mariadb with correct ownership and permissions +install -d -o mysql -g mysql -m 0755 /run/mariadb diff --git a/wsl/roles/system/vars/main.yml b/wsl/roles/system/vars/main.yml index e9a659d..b915f62 100644 --- a/wsl/roles/system/vars/main.yml +++ b/wsl/roles/system/vars/main.yml @@ -1,3 +1,5 @@ --- wsl_config_dest: /etc/wsl.conf bash_profile_dest: "/home/{{ config.system.username }}/.bash_profile" +runtime_directories_script_path: "/usr/local/bin/runtime-directories.sh" +runtime_directories_service_path: "/etc/systemd/system/runtime-directories.service"