Skip to content

Commit 89502d9

Browse files
committed
Added service responsible with re/creating runtime directories
Signed-off-by: alexmerlin <[email protected]>
1 parent 0103bbb commit 89502d9

File tree

7 files changed

+45
-26
lines changed

7 files changed

+45
-26
lines changed

wsl/install.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414
name: "{{ role }}"
1515
tasks_from: main
1616
loop:
17-
- system
1817
- apache
1918
- php
2019
- mariadb
2120
- phpmyadmin
21+
- system
2222
- composer
2323
- nodejs
2424
- git

wsl/roles/apache/tasks/main.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,6 @@
55
- httpd
66
- httpd-tools
77
state: latest
8-
- name: Ensure /run/httpd directory exists on Apache startup
9-
ansible.builtin.lineinfile:
10-
path: "{{ etc_rc_d_rc_local_path }}"
11-
line: "{{ item }}"
12-
create: yes
13-
insertafter: EOF
14-
loop:
15-
- "# Ensure /run/httpd directory exists on Apache startup"
16-
- "/usr/bin/mkdir -p /run/httpd"
17-
- "/usr/bin/install -d -o apache -g apache -m 0755 /run/httpd"
188
- name: Enable and start Apache service
199
command: systemctl enable --now httpd
2010
- name: Fix Apache home directory ownership

wsl/roles/mariadb/tasks/main.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
---
22
- name: Install MariaDB 11.4
33
command: "dnf install python3-mysqlclient mariadb-server -y"
4-
- name: Ensure /run/mariadb directory exists on MariaDB startup
5-
ansible.builtin.lineinfile:
6-
path: "{{ etc_rc_d_rc_local_path }}"
7-
line: "{{ item }}"
8-
create: yes
9-
insertafter: EOF
10-
loop:
11-
- "# Ensure /run/mariadb directory exists on MariaDB startup"
12-
- "/usr/bin/mkdir -p /run/mariadb"
13-
- "/usr/bin/chown mysql:mysql /run/mariadb"
144
- name: Enable and start MariaDB service
155
command: systemctl enable --now mariadb
166
- name: Set MariaDB root password

wsl/roles/system/tasks/main.yml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,24 @@
2222
template:
2323
src: bash_profile.j2
2424
dest: "{{ bash_profile_dest }}"
25-
- name: Ensure /etc/rc.d/rc.local is executable
26-
file:
27-
path: "{{ etc_rc_d_rc_local_path }}"
28-
mode: '0755'
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 & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
22
wsl_config_dest: /etc/wsl.conf
33
bash_profile_dest: "/home/{{ config.system.username }}/.bash_profile"
4-
etc_rc_d_rc_local_path: "/etc/rc.d/rc.local"
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)