Compare commits

...

8 Commits

Author SHA1 Message Date
uumas
728a57347d v0.5.20 2026-03-15 22:27:04 +02:00
uumas
6abb365090 Fix typo 2026-03-15 22:26:00 +02:00
uumas
20a4e1d582 caddy: Set udp request buffers in sysctl 2026-03-15 22:00:14 +02:00
uumas
97d7fab538 v0.5.19 2026-03-12 03:11:25 +02:00
uumas
499f042c75 Add systemd_socket role 2026-03-12 03:10:22 +02:00
uumas
5b2b612b22 v0.5.18 2026-03-12 00:53:35 +02:00
uumas
2b26209074 systemd: document need for noqa 2026-03-12 00:53:14 +02:00
uumas
68a40fef1b Add systemd role for restarting multiple services in same transaction 2026-03-11 22:25:02 +02:00
12 changed files with 82 additions and 1 deletions

View File

@@ -2,7 +2,7 @@
namespace: uumas
name: general
description: General roles
version: 0.5.17
version: 0.5.20
readme: README.md
authors:
- uumas

View File

@@ -1,4 +1,14 @@
---
- name: Set sysctl udp buffer sizes for caddy
ansible.posix.sysctl:
name: "{{ item.key }}"
value: "{{ item.value }}"
state: present
reload: true
with_dict:
net.core.rmem_max: "7500000"
net.core.wmem_max: "7500000"
- name: Ensure legacy caddy apt repository not present
ansible.builtin.file:
path: /etc/apt/sources.list.d/caddy-stable.list

9
roles/systemd/README.md Normal file
View File

@@ -0,0 +1,9 @@
Adds systemd-related notifiable handlers
- Reload systemd daemon
- Reloads all systemd unit files
- Apply systemd unit restarts
- Restarts multiple systemd units in a single transaction
- Units to be restarted are defined in the `systemd_restart_units` variable of type list
- The variable should be set using `ansible.builtin.set_fact`, with `# noqa: var-naming[no-role-prefix]`
- The list must not be overridden, but appended (`systemd_restart_units: "{{ systemd_restart_units + ['restartme.service'] }}"`

View File

@@ -0,0 +1,2 @@
---
systemd_restart_units: []

View File

@@ -0,0 +1,14 @@
---
- name: Reload systemd daemon
ansible.builtin.systemd_service:
daemon_reload: true
- name: Apply systemd unit restarts # noqa: command-instead-of-module
ansible.builtin.command:
cmd: systemctl restart {{ systemd_restart_units | join(' ') }}
changed_when: true
- name: Reset systemd restart units
listen: Apply systemd unit restarts
ansible.builtin.set_fact:
systemd_restart_units: []

View File

@@ -0,0 +1 @@
Adds a systemd socket for a service

View File

@@ -0,0 +1,2 @@
---
systemd_socket_requires: []

View File

@@ -0,0 +1,6 @@
---
- name: Restart socket {{ systemd_socket_name }}
ansible.builtin.set_fact:
systemd_restart_units: "{{ systemd_restart_units + [systemd_socket_name ~ '.socket'] }}" # noqa: var-naming[no-role-prefix]
changed_when: true
notify: Apply systemd unit restarts

View File

@@ -0,0 +1,16 @@
---
argument_specs:
main:
description:
- Adds a systemd socket for a service
options:
systemd_socket_name:
description: Name of the socket. The socket will be created at /run/<systemd_socket_name>.sock
type: str
required: true
systemd_socket_requires:
description: List of units this socket depends on.
type: list
required: false
default: []
elements: str

View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: systemd

View File

@@ -0,0 +1,9 @@
---
- name: Socket {{ systemd_socket_name }}
ansible.builtin.template:
src: socket.j2
dest: /etc/systemd/system/{{ systemd_socket_name }}.socket
mode: "0644"
notify:
- Reload systemd daemon
- Restart socket {{ systemd_socket_name }}

View File

@@ -0,0 +1,9 @@
# {{ ansible_managed }}
[Unit]
Description={{ systemd_socket_name }} socket
{% for item in systemd_socket_requires %}
Requires={{ item }}
{% endfor %}
[Socket]
ListenStream=/run/{{ systemd_socket_name }}.sock